Class: Wakame::TimedCounter

Inherits:
InstanceCounter show all
Defined in:
lib/wakame/instance_counter.rb

Constant Summary

Constants included from AttributeHelper

AttributeHelper::CLASS_TYPE_KEY, AttributeHelper::CONVERT_CLASSES, AttributeHelper::PRIMITIVE_CLASSES

Instance Method Summary collapse

Methods inherited from InstanceCounter

#bind_resource, #resource

Methods included from AttributeHelper

#dump_attrs, #retrieve_attr_attribute

Constructor Details

#initialize(seq, resource) ⇒ TimedCounter

Returns a new instance of TimedCounter.



47
48
49
50
51
52
53
# File 'lib/wakame/instance_counter.rb', line 47

def initialize(seq, resource)
  @sequence = seq
  bind_resource(resource)
  @timer = Scheduler::SequenceTimer.new(seq)
  @timer.add_observer(self)
  @instance_count = 1
end

Instance Method Details

#instance_countObject



55
56
57
# File 'lib/wakame/instance_counter.rb', line 55

def instance_count
  @instance_count
end

#update(*args) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/wakame/instance_counter.rb', line 59

def update(*args)
  new_count = args[0]
  if @instance_count != count
    prev = @instance_count
    @instance_count = count
    ED.fire_event(Event::InstanceCountChanged.new(@resource, prev, count))
  end
  #if self.min > new_count || self.max < new_count
  #if self.min != new_count || self.max != new_count
  #  prev_min = self.min
  #  prev_max = self.max
  
  #  self.max = self.min = new_count
  #  ED.fire_event(Event::InstanceCountChanged.new(@resource, prev_min, prev_max, self.min, self.max))
  #end
  
end