Class: TimeArray::CompactorTime

Inherits:
Object
  • Object
show all
Defined in:
lib/time_array/compactor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#timeObject (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