timerizer 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/timerizer.rb +15 -2
- metadata +1 -1
data/lib/timerizer.rb
CHANGED
@@ -414,11 +414,18 @@ class WallClock
|
|
414
414
|
# @param [Fixnum] minute The minute to initialize with
|
415
415
|
# @param [Fixnum] second The second to initialize with
|
416
416
|
# @param [Symbol] meridiem The meridiem to initialize with (`:am` or `:pm`)
|
417
|
+
# @overload new(seconds)
|
418
|
+
# @param [Fixnum] seconds The number of seconds to initialize with (for use with #to_i)
|
417
419
|
# @raise InvalidMeridiemError Meridiem is not `:am` or `:pm`
|
418
|
-
def initialize(hour =
|
419
|
-
|
420
|
+
def initialize(hour = nil, minute = nil, second = 0, meridiem = :am)
|
421
|
+
units = nil
|
422
|
+
if hour.is_a?(Fixnum) && minute.nil?
|
423
|
+
units = {:second => hour}
|
424
|
+
elsif hour.is_a?(Hash)
|
420
425
|
units = hour
|
426
|
+
end
|
421
427
|
|
428
|
+
if !units.nil?
|
422
429
|
second = units[:second] || 0
|
423
430
|
minute = units[:minute] || 0
|
424
431
|
hour = units[:hour] || 0
|
@@ -541,6 +548,12 @@ class WallClock
|
|
541
548
|
@seconds.seconds
|
542
549
|
end
|
543
550
|
|
551
|
+
# Get the time of the WallClock in a more portable format (for a database, for example)
|
552
|
+
# @see #in_seconds
|
553
|
+
def to_i
|
554
|
+
self.in_seconds
|
555
|
+
end
|
556
|
+
|
544
557
|
# Convert {WallClock} to a human-readable format.
|
545
558
|
# @param [Symbol] system The hour system to use (`:twelve_hour` or `:twenty_four_hour`; default `:twelve_hour`)
|
546
559
|
# @example
|