るりまサーチ

最速Rubyリファレンスマニュアル検索!
38件ヒット [1-38件を表示] (0.019秒)
トップページ > クラス:DateTime[x] > クエリ:Hash[x]

別のキーワード

  1. _builtin hash
  2. hash []
  3. matrix hash
  4. dbm to_hash
  5. _builtin to_hash

ライブラリ

キーワード

検索結果

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

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

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

キーに利用できる名前は以下の通りです。

* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :sec_fraction
* :zone

@param array_of_names_or_nil パターンマッチに使...
...用する名前の配列を指定します。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 (108.0)

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

...JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

@param hash 適切なキーを持つハッシュを指定します。...

DateTime._strptime(str, format = '%FT%T%z') -> Hash (102.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 (19.0)

自身を JSON 形式の文字列に変換して返します。

...erator::GeneratorMethods::Hash#to_json を呼び出しています。

@param 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 JSON::Generator::GeneratorMethods::Hash#to_json...