class Tomlrb::LocalTime
Public Class Methods
Source
# File lib/tomlrb/local_time.rb, line 11 def initialize(hour, min, sec) @time = Time.utc(0, 1, 1, hour, min, sec) raise ArgumentError, "Invalid Local Time: #{hour}-#{min}-#{sec}" unless min.to_i == @time.min && hour.to_i == @time.hour @sec = sec end
Public Instance Methods
Source
# File lib/tomlrb/local_time.rb, line 32 def ==(other) other.is_a?(self.class) && @time == other.to_time(0, 1, 1) end
Source
# File lib/tomlrb/local_time.rb, line 37 def inspect "#<#{self.class}: #{self}>" end
Source
# File lib/tomlrb/local_time.rb, line 26 def to_s frac = (@sec - sec) frac_str = frac.zero? ? '' : frac.to_s[1..-1] @time.strftime('%T') << frac_str end
Source
# File lib/tomlrb/local_time.rb, line 22 def to_time(year, month, day, offset = '-00:00') Time.new(year, month, day, hour, min, @sec, offset) end
@param year [Integer] @param month [Integer] @param day [Integer] @param offset see {LocalDateTime#to_time} @return [Time] the time of the date specified by params