るりまサーチ

最速Rubyリファレンスマニュアル検索!
16件ヒット [1-16件を表示] (0.061秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

クラス

キーワード

検索結果

DateTime#deconstruct_keys(array_of_names_or_nil) -> Hash (3115.0)

パターンマッチに使用する名前と値の Hash を返します。

...hour
* :min
* :sec
* :sec_fraction
* :zone

@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//emlist[例][ruby]{
dt = DateTime.new(2022, 10, 5, 13, 30)

i
f dt in wday: 1....
...nstruct_keys が使われます
puts "Working time"
end
#=> "Working time" が出力される

case dt
i
n year: ...2022
puts "too old"
i
n month: ..9
puts "quarter 1-3"
i
n wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in month 10" が出力される

# クラス...
...のチェックと組み合わせて利用することもできます
i
f dt in DateTime(wday: 1..5, hour: 10..18, day: ..7)
puts "Working time, first week of the month"
end
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Date#<=>(other) -> -1 | 0 | 1 | nil (115.0)

二つの日付を比較します。 同じ日付なら 0 を、self が other よりあとの日付なら 1 を、 その逆なら -1 を返します。

...で nil を返します。

//emlist[][ruby]{
require "date"

p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 4) # => -1
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 3) # => 0
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 2) # => 1
p Date.new(2001, 2, 3) <=> Object.new # => nil
p Date.new(2001...
..., 2, 3) <=> Rational(4903887, 2) # => 0
//}

@param other 日付オブジェクトまたは数値...

Date#deconstruct_keys(array_of_names_or_nil) -> Hash (115.0)

パターンマッチに使用する名前と値の Hash を返します。

...ray_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//emlist[例][ruby]{
d = Date.new(2022, 10, 5)

i
f d in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of...
...the month"
end
#=> "first Wednesday of the month" が出力される

case d
i
n year: ...2022
puts "too old"
i
n month: ..9
puts "quarter 1-3"
i
n wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in month 10" が出力される

# クラスのチェックと組み合...
...わせて利用することもできます
i
f d in Date(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...