Class: Tomlrb::LocalDate
- Inherits:
-
Object
- Object
- Tomlrb::LocalDate
- Extended by:
- Forwardable
- Defined in:
- lib/tomlrb/local_date.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(year, month, day) ⇒ LocalDate
constructor
A new instance of LocalDate.
- #inspect ⇒ Object
- #to_s ⇒ Object
-
#to_time(offset = '-00:00') ⇒ Time
00:00:00 of the date.
Constructor Details
#initialize(year, month, day) ⇒ LocalDate
Returns a new instance of LocalDate.
9 10 11 |
# File 'lib/tomlrb/local_date.rb', line 9 def initialize(year, month, day) @time = Time.new(year, month, day, 0, 0, 0, '-00:00') end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 27 |
# File 'lib/tomlrb/local_date.rb', line 24 def ==(other) other.kind_of?(self.class) && to_time == other.to_time end |
#inspect ⇒ Object
29 30 31 |
# File 'lib/tomlrb/local_date.rb', line 29 def inspect "#<#{self.class}: #{to_s}>" end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/tomlrb/local_date.rb', line 20 def to_s @time.strftime('%F') end |
#to_time(offset = '-00:00') ⇒ Time
Returns 00:00:00 of the date.
15 16 17 18 |
# File 'lib/tomlrb/local_date.rb', line 15 def to_time(offset='-00:00') return @time if offset == '-00:00' Time.new(year, month, day, 0, 0, 0, offset) end |