Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/date/constructor.rb
Overview
Allow a Date to be constructed from any Date or DateTime subclass, or parsed from a String
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*a, &b) ⇒ Date
constructor
If someone calls allocate/initialize, make that work …
Constructor Details
Class Method Details
.new(*a, &b) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/date/constructor.rb', line 11 def self.new *a, &b if a[0].is_a?(String) parse(*a) elsif (a.size == 1) case a[0] when DateTime civil(a[0].year, a[0].month, a[0].day, a[0].start) when Date a[0].clone else civil(*a, &b) end else civil(*a, &b) end end |