D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
DateTime
/
Filename :
deconstruct_keys-i.ri
back
Copy
U:RDoc::AnyMethod[iI"deconstruct_keys:ETI"DateTime#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"D<tt>:wday</tt>, <tt>:yday</tt>, <tt>:hour</tt>, <tt>:min</tt>, ;TI";<tt>:sec</tt>, <tt>:sec_fraction</tt>, <tt>:zone</tt>.;To:RDoc::Markup::BlankLine o; ; [I"Possible usages:;T@o:RDoc::Markup::Verbatim; [I",dt = DateTime.new(2022, 10, 5, 13, 30) ;TI" ;TI"Jif d in wday: 1..5, hour: 10..18 # uses deconstruct_keys underneath ;TI" puts "Working time" ;TI" end ;TI"#=> prints "Working time" ;TI" ;TI" case dt ;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 DateTime(wday: 1..5, hour: 10..18, day: ..7) ;TI"4 puts "Working time, first week 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" DateTime;TcRDoc::NormalClass00