8件ヒット
[1-8件を表示]
(0.011秒)
ライブラリ
- ビルトイン (8)
キーワード
-
deconstruct
_ keys (2) - inspect (6)
検索結果
-
Time
# inspect -> String (6101.0) -
時刻を文字列に変換した結果を返します。
...します。
Time#to_s とは異なりナノ秒まで含めて返します。
//emlist[][ruby]{
t = Time.now
t.inspect #=> "2012-11-10 18:16:12.261257655 +0100"
t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100"
t.utc.inspect......#=> "2012-11-10 17:16:12.261257655 UTC"
t.strftime "%Y-%m-%d %H:%M:%S.%N UTC" #=> "2012-11-10 17:16:12.261257655 UTC"
//}
戻り値の文字エンコーディングは Encoding::US_ASCII です。... -
Time
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (7.0) -
パターンマッチに使用する名前と値の Hash を返します。
...チに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
t = Time.utc(2022, 10, 5, 21, 25, 30)
if t in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first......ng 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...