Class: TimeSpanner::TimeUnits::Unit
- Inherits:
-
Object
- Object
- TimeSpanner::TimeUnits::Unit
- Includes:
- Comparable
- Defined in:
- lib/time_spanner/time_units/base/unit.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#rest ⇒ Object
Returns the value of attribute rest.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(position) ⇒ Unit
constructor
A new instance of Unit.
- #plural_name ⇒ Object
- #reverse! ⇒ Object
Constructor Details
#initialize(position) ⇒ Unit
10 11 12 13 14 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 10 def initialize position @position = position @amount = 0 @rest = 0 end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
8 9 10 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 8 def amount @amount end |
#duration ⇒ Object
Returns the value of attribute duration.
8 9 10 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 8 def duration @duration end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
7 8 9 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 7 def position @position end |
#rest ⇒ Object
Returns the value of attribute rest.
8 9 10 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 8 def rest @rest end |
Instance Method Details
#<=>(other) ⇒ Object
20 21 22 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 20 def <=> other position <=> other.position end |
#plural_name ⇒ Object
24 25 26 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 24 def plural_name "#{self.class.name.split('::').last.downcase}s".to_sym end |
#reverse! ⇒ Object
16 17 18 |
# File 'lib/time_spanner/time_units/base/unit.rb', line 16 def reverse! @amount = -amount end |