るりまサーチ

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

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. matrix i
  5. csv to_i

ライブラリ

キーワード

検索結果

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)

i
f dt in wday: 1..5, hour: 10..18 # deconstruct_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 m...
...#=> "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_object...