Class: TimeArray::CompactorTime
- Inherits:
-
Object
- Object
- TimeArray::CompactorTime
- Defined in:
- lib/time_array/compactor.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #change(step = :hour) ⇒ Object
- #increment(step = :hour) ⇒ Object
- #increment!(step = :hour) ⇒ Object
-
#initialize(t) ⇒ CompactorTime
constructor
A new instance of CompactorTime.
Constructor Details
#initialize(t) ⇒ CompactorTime
Returns a new instance of CompactorTime.
6 7 8 9 |
# File 'lib/time_array/compactor.rb', line 6 def initialize(t) @time = t # @time = Time.new(t.year, t.month, t.day, t.hour, 0, 0) end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/time_array/compactor.rb', line 5 def time @time end |
Instance Method Details
#change(step = :hour) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/time_array/compactor.rb', line 11 def change(step=:hour) nxt = @time+1.send(step) [:year, :month, :day, :hour].each do |st| return st if nxt.send(st)!=@time.send(st) end end |
#increment(step = :hour) ⇒ Object
18 19 20 |
# File 'lib/time_array/compactor.rb', line 18 def increment(step=:hour) @time+1.send(step) end |
#increment!(step = :hour) ⇒ Object
22 23 24 |
# File 'lib/time_array/compactor.rb', line 22 def increment!(step=:hour) @time = increment(step) end |