D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Date
/
Filename :
deconstruct_keys-i.ri
back
Copy
U:RDoc::AnyMethod[iI"deconstruct_keys:ETI"Date#deconstruct_keys;TF:publico:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Paragraph; [I"IReturns a hash of the name/value pairs, to use in pattern matching. ;TI"HPossible keys are: <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, ;TI"$<tt>:wday</tt>, <tt>:yday</tt>.;To:RDoc::Markup::BlankLine o; ; [I"Possible usages:;T@o:RDoc::Markup::Verbatim; [I"d = Date.new(2022, 10, 5) ;TI" ;TI"Cif d in wday: 3, day: ..7 # uses deconstruct_keys underneath ;TI"+ puts "first Wednesday of the month" ;TI" end ;TI"/#=> prints "first Wednesday of the month" ;TI" ;TI"case d ;TI"in year: ...2022 ;TI" puts "too old" ;TI"in month: ..9 ;TI" puts "quarter 1-3" ;TI"in wday: 1..5, month: ;TI", puts "working day in month #{month}" ;TI" end ;TI"*#=> prints "working day in month 10" ;T:@format0o; ; [I"ONote that deconstruction by pattern can also be combined with class check:;T@o;; [I"%if d in Date(wday: 3, day: ..7) ;TI"+ puts "first Wednesday of the month" ;TI"end;T; 0: @fileI"ext/date/date_core.c;T:0@omit_headings_from_table_of_contents_below0I"5deconstruct_keys(array_of_names_or_nil) -> hash ;T0[ I" (p1);T@.FI" Date;TcRDoc::NormalClass00