12件ヒット
[1-12件を表示]
(0.085秒)
ライブラリ
- date (1)
-
json
/ add / date _ time (11)
キーワード
-
deconstruct
_ keys (1) -
to
_ json (11)
検索結果
-
DateTime
# to _ json(*args) -> String (3201.0) -
自身を JSON 形式の文字列に変換して返します。
...args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。
//emlist[例][ruby]{
require "json/add/core"
DateTime.now.to_json
# => "{\"json_class\":\"DateTime\",\"y\":2018,\"m\":12,\"d\":10,\"H\":1,\"M\":28,\"S\":57,\"of\":\"3/8\",\"sg\":2299161.0}"
//}
@see J... -
DateTime
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (3161.0) -
パターンマッチに使用する名前と値の Hash を返します。
...す。
* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :sec_fraction
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][r......dt = DateTime.new(2022, 10, 5, 13, 30)
if dt in wday: 1..5, hour: 10..18 # deconstruct_keys が使われます
puts "Working time"
end
#=> "Working time" が出力される
case dt
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in m......#=> "working day in month 10" が出力される
# クラスのチェックと組み合わせて利用することもできます
if 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_object...