4件ヒット
[1-4件を表示]
(0.018秒)
種類
- 特異メソッド (2)
- インスタンスメソッド (2)
ライブラリ
- date (2)
-
json
/ add / date _ time (2)
キーワード
-
_ strptime (1) -
deconstruct
_ keys (1) -
json
_ create (1) -
to
_ json (1)
検索結果
先頭4件
-
DateTime
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (355.0) -
パターンマッチに使用する名前と値の Hash を返します。
...に使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
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"......}"
end
#=> "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_... -
DateTime
. json _ create(hash) -> DateTime (325.0) -
JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
JSON のオブジェクトから Ruby のオブジェクトを生成して返します。
@param hash 適切なキーを持つハッシュを指定します。 -
DateTime
. _ strptime(str , format = & # 39;%FT%T%z& # 39;) -> Hash (307.0) -
与えられた雛型で日時表現を解析し、その情報に基づいてハッシュを生成します。
...す文字列
@param format 書式
例:
require 'date'
DateTime._strptime('2001-02-03T12:13:14Z')
# => {:year=>2001, :mon=>2, :mday=>3, :hour=>12, :min=>13, :sec=>14, :zone=>"Z", :offset=>0}
DateTime.strptime の内部で使用されています。
@see Date._strptime, DateTime.strptime... -
DateTime
# to _ json(*args) -> String (58.0) -
自身を JSON 形式の文字列に変換して返します。
...まま 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 JSON::Generator::Gene...