Class: Timely::Period
- Inherits:
-
Object
- Object
- Timely::Period
- Defined in:
- lib/timely/rails/period.rb
Constant Summary collapse
- UNITS =
[ :seconds, :minutes, :hours, :days, :weeks, :months, :years, :calendar_days, :calendar_months, :calendar_years ]
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Instance Method Summary collapse
- #after(time) ⇒ Object
-
#initialize(number, units) ⇒ Period
constructor
A new instance of Period.
- #to_s ⇒ Object
Constructor Details
#initialize(number, units) ⇒ Period
Returns a new instance of Period.
18 19 20 21 |
# File 'lib/timely/rails/period.rb', line 18 def initialize(number, units) @number = number @units = units.to_sym end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/timely/rails/period.rb', line 3 def number @number end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
3 4 5 |
# File 'lib/timely/rails/period.rb', line 3 def units @units end |
Instance Method Details
#after(time) ⇒ Object
23 24 25 |
# File 'lib/timely/rails/period.rb', line 23 def after(time) time.advance_considering_calendar(units, number) end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/timely/rails/period.rb', line 27 def to_s "#{number} #{units.to_s.gsub('_', '')}" end |