Class: Tomlrb::LocalTime
- Inherits:
-
Object
- Object
- Tomlrb::LocalTime
- Extended by:
- Forwardable
- Defined in:
- lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(hour, min, sec) ⇒ LocalTime
constructor
A new instance of LocalTime.
- #inspect ⇒ Object
- #to_s ⇒ Object
-
#to_time(year, month, day, offset = '-00:00') ⇒ Time
The time of the date specified by params.
Constructor Details
#initialize(hour, min, sec) ⇒ LocalTime
Returns a new instance of LocalTime.
11 12 13 14 |
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb', line 11 def initialize(hour, min, sec) @time = Time.new(0, 1, 1, hour, min, sec, '-00:00') @sec = sec end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 |
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb', line 31 def ==(other) other.is_a?(self.class) && @time == other.to_time(0, 1, 1) end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb', line 36 def inspect "#<#{self.class}: #{self}>" end |
#to_s ⇒ Object
25 26 27 28 29 |
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb', line 25 def to_s frac = (@sec - sec) frac_str = frac.zero? ? '' : frac.to_s[1..-1] @time.strftime('%T') << frac_str end |
#to_time(year, month, day, offset = '-00:00') ⇒ Time
Returns the time of the date specified by params.
21 22 23 |
# File 'lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb', line 21 def to_time(year, month, day, offset = '-00:00') Time.new(year, month, day, hour, min, @sec, offset) end |