Method: Timerizer::WallClock.from_string

Defined in:
lib/timerizer/wall_clock.rb

.from_string(string) ⇒ WallClock

Takes a string and turns it into a WallClock time

Examples:

WallClock.from_string("10:30 PM")
  # => 10:30:00 PM
WallClock.from_string("13:01:23")
  # => 1:01:23 PM

Parameters:

  • string (String)

    The string to convert

Returns:

See Also:



76
77
78
79
80
# File 'lib/timerizer/wall_clock.rb', line 76

def self.from_string(string)
  time, meridiem = string.split(' ', 2)
  hour, minute, second = time.split(':', 3)
  WallClock.new(hour.to_i, minute.to_i, second.to_i || 0, meridiem || :am)
end