timerizer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/timerizer.rb +15 -2
  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 = 0, minute = 0, second = 0, meridiem = :am)
419
- if hour.is_a?(Hash)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timerizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: