4件ヒット
[1-4件を表示]
(0.070秒)
別のキーワード
ライブラリ
- date (3)
-
json
/ add / date (1)
キーワード
-
deconstruct
_ keys (1) -
next
_ year (1) -
prev
_ year (1) -
to
_ json (1)
検索結果
先頭4件
-
Date
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (18343.0) -
パターンマッチに使用する名前と値の Hash を返します。
...チに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
d = Date.new(2022, 10, 5)
if d in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of......g day in month #{month}"
end
#=> "working day in month 10" が出力される
# クラスのチェックと組み合わせて利用することもできます
if d in Date(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}
@see d:spec/pattern_matching#matching_non_primitive_objects... -
Date
# next _ year(n = 1) -> Date (18343.0) -
n 年後を返します。
...相当します。
//emlist[例][ruby]{
require 'date'
Date.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...>
Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
//}
Date#>> も参照してください。
@param n 年... -
Date
# prev _ year(n = 1) -> Date (18343.0) -
n 年前を返します。
...相当します。
//emlist[例][ruby]{
require 'date'
Date.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...>
Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
//}
Date#<< も参照してください。
@param n 年... -
Date
# to _ json(*args) -> String (61.0) -
自身を JSON 形式の文字列に変換して返します。
...args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。
//emlist[例][ruby]{
require "json/add/core"
Date.today.to_json
# => "{\"json_class\":\"Date\",\"y\":2018,\"m\":12,\"d\":11,\"sg\":2299161.0}"
//}
@see JSON::Generator::GeneratorMethods::Hash#to_json...