Class: Timely::Period
- Inherits:
-
Object
- Object
- Timely::Period
- Defined in:
- lib/timely/rails/period.rb
Constant Summary collapse
- UNITS =
i[ seconds minutes hours days weeks months years calendar_days calendar_months calendar_years ].freeze
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.
20 21 22 23 |
# File 'lib/timely/rails/period.rb', line 20 def initialize(number, units) @number = number @units = units.to_sym end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/timely/rails/period.rb', line 5 def number @number end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
5 6 7 |
# File 'lib/timely/rails/period.rb', line 5 def units @units end |
Instance Method Details
#after(time) ⇒ Object
25 26 27 |
# File 'lib/timely/rails/period.rb', line 25 def after(time) time.advance_considering_calendar(units, number) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/timely/rails/period.rb', line 29 def to_s "#{number} #{units.to_s.gsub('_', '')}" end |