Class: TimeLord::Period
- Inherits:
-
Object
- Object
- TimeLord::Period
- Defined in:
- lib/time-lord/period.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #difference ⇒ Object (also: #to_i)
-
#initialize(beginning, ending) ⇒ Period
constructor
A new instance of Period.
- #to_range ⇒ Object
- #to_time ⇒ Object
- #to_words ⇒ Object (also: #in_words)
Constructor Details
#initialize(beginning, ending) ⇒ Period
Returns a new instance of Period.
5 6 7 8 |
# File 'lib/time-lord/period.rb', line 5 def initialize(beginning, ending) self.beginning = beginning self.ending = ending end |
Instance Attribute Details
#beginning ⇒ Object
28 29 30 |
# File 'lib/time-lord/period.rb', line 28 def beginning @beginning.to_i end |
#ending ⇒ Object
32 33 34 |
# File 'lib/time-lord/period.rb', line 32 def ending @ending.to_i end |
Instance Method Details
#difference ⇒ Object Also known as: to_i
15 16 17 |
# File 'lib/time-lord/period.rb', line 15 def difference beginning - ending end |
#to_range ⇒ Object
24 25 26 |
# File 'lib/time-lord/period.rb', line 24 def to_range beginning..ending end |
#to_time ⇒ Object
20 21 22 |
# File 'lib/time-lord/period.rb', line 20 def to_time if difference < 0 then @beginning else @ending end end |
#to_words ⇒ Object Also known as: in_words
10 11 12 |
# File 'lib/time-lord/period.rb', line 10 def to_words "#{value} #{unit} #{tense}" end |