Sha256: a2d800fb88f482cfecc41a753916b4c1042b214aab41e917a08b532fa353f48b

Contents?: true

Size: 691 Bytes

Versions: 3

Compression:

Stored size: 691 Bytes

Contents

module Dkron
  class NumericSeconds
    attr_reader :number

    def self.seconds(number, units)
      new(number).send(units)
    end

    def initialize(number)
      @number = number.to_i
    end

    def seconds
      number
    end
    alias :second :seconds

    def minutes
      number * 60
    end
    alias :minute :minutes

    def hours
      number * 3_600
    end
    alias :hour :hours

    def days
      number * 86_400
    end
    alias :day :days

    def weeks
      number * 604_800
    end
    alias :week :weeks

    def months
      number * 2_592_000
    end
    alias :month :months

    def years
      number * 31_557_600
    end
    alias :year :years
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dkron-rb-0.11.2 lib/dkron-rb/numeric_seconds.rb
dkron-rb-0.10.0 lib/dkron-rb/numeric_seconds.rb
dkron-rb-0.9.2 lib/dkron-rb/numeric_seconds.rb