Sha256: 3bff87bd650a8372817bb737e92ddaab1c85c25dcc10d56b539cf924944de576

Contents?: true

Size: 509 Bytes

Versions: 9

Compression:

Stored size: 509 Bytes

Contents

module Timely
  class Period
    attr_reader :number, :units

    UNITS = [
      :seconds,
      :minutes,
      :hours,
      :days,
      :weeks,
      :months,
      :years,
      :calendar_days,
      :calendar_months,
      :calendar_years
    ]

    def initialize(number, units)
      @number = number
      @units  = units.to_sym
    end

    def after(time)
      time.advance_considering_calendar(units, number)
    end

    def to_s
      "#{number} #{units.to_s.gsub('_', '')}"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
timely-0.5.0 lib/timely/rails/period.rb
timely-0.4.2 lib/timely/rails/period.rb
timely-0.4.1 lib/timely/rails/period.rb
timely-0.4.0 lib/timely/rails/period.rb
timely-0.3.4 lib/timely/rails/period.rb
timely-0.3.2 lib/timely/rails/period.rb
timely-0.3.1 lib/timely/rails/period.rb
timely-0.3.0 lib/timely/rails/period.rb
timely-0.1.0 lib/timely/rails/period.rb