23件ヒット
[1-23件を表示]
(0.023秒)
別のキーワード
クラス
- Time (23)
キーワード
-
deconstruct
_ keys (1) -
to
_ a (11)
検索結果
-
Time
# wday -> Integer (18146.0) -
曜日を0(日曜日)から6(土曜日)の整数で返します。
...p sun.wday # => 0
p mon = Time.new(2017, 9, 18, 10, 34, 15, '+09:00') # => 2017-09-18 10:34:15 +0900
p mon.wday # => 1
p tue = Time.new(2017, 9, 19, 10, 34, 15, '+09:00') # => 2017-09-19 10:34:15 +0900
p tue.wday......p wed.wday # => 3
p thu = Time.new(2017, 9, 21, 10, 34, 15, '+09:00') # => 2017-09-21 10:34:15 +0900
p thu.wday # => 4
p fri = Time.new(2017, 9, 22, 10, 34, 15, '+09:00') # => 2017-09-22 10:34:15 +0900
p fri.wday......# => 5
p sat = Time.new(2017, 9, 23, 10, 34, 15, '+09:00') # => 2017-09-23 10:34:15 +0900
p sat.wday # => 6
//}... -
Time
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (27.0) -
パターンマッチに使用する名前と値の Hash を返します。
...る名前と値の Hash を返します。
キーに利用できる名前は以下の通りです。
* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指......022, 10, 5, 21, 25, 30)
if t in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される
case t
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working......day in month #{month}"
end
#=> "working day in month 10" が出力される
# クラスのチェックと組み合わせて利用することもできます
if t in Time(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
Time
# to _ a -> Array (9.0) -
時刻を10要素の配列で返します。
...min: 分 (整数 0-59)
* hour: 時 (整数 0-23)
* mday: 日 (整数)
* mon: 月 (整数 1-12)
* year: 年 (整数 2000年=2000)
* wday: 曜日 (整数 0-6)
* yday: 年内通算日 (整数 1-366)
* isdst: 夏時間であるかどうか (true/false)
* zone: タイムゾー...