D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Time
/
Filename :
deconstruct_keys-i.ri
back
Copy
U:RDoc::AnyMethod[iI"deconstruct_keys:ETI"Time#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"S<tt>:yday</tt>, <tt>:wday</tt>, <tt>:hour</tt>, <tt>:min</tt>, <tt>:sec</tt>, ;TI"5<tt>:subsec</tt>, <tt>:dst</tt>, <tt>:zone</tt>.;To:RDoc::Markup::BlankLine o; ; [I"Possible usages:;T@o:RDoc::Markup::Verbatim; [I"+t = Time.utc(2022, 10, 5, 21, 25, 30) ;TI" ;TI"Cif t 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 t ;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 t in Time(wday: 3, day: ..7) ;TI"+ puts "first Wednesday of the month" ;TI"end;T; 0: @fileI"time.c;T:0@omit_headings_from_table_of_contents_below0I"5deconstruct_keys(array_of_names_or_nil) -> hash ;T0[ I" (p1);T@/FI" Time;TcRDoc::NormalClass00