Class: ScavengerHunt::Time
- Inherits:
-
Object
- Object
- ScavengerHunt::Time
- Defined in:
- lib/scavenger_hunt/app/models/scavenger_hunt/time.rb
Instance Attribute Summary collapse
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
Instance Method Summary collapse
- #+(other_time) ⇒ Object
-
#initialize(seconds) ⇒ Time
constructor
A new instance of Time.
- #to_s ⇒ Object
Constructor Details
#initialize(seconds) ⇒ Time
Returns a new instance of Time
4 5 6 |
# File 'lib/scavenger_hunt/app/models/scavenger_hunt/time.rb', line 4 def initialize(seconds) @seconds = seconds end |
Instance Attribute Details
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds
2 3 4 |
# File 'lib/scavenger_hunt/app/models/scavenger_hunt/time.rb', line 2 def seconds @seconds end |
Instance Method Details
#+(other_time) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/scavenger_hunt/app/models/scavenger_hunt/time.rb', line 8 def +(other_time) case other_time when ScavengerHunt::Time return self.class.new(seconds + other_time.seconds) else return self.class.new(seconds + other_time) end end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/scavenger_hunt/app/models/scavenger_hunt/time.rb', line 17 def to_s Time.at(seconds).utc.strftime("%H:%M:%S") end |