Class: JIJI::PeriodicallyAgent
- Inherits:
-
Object
- Object
- JIJI::PeriodicallyAgent
- Includes:
- Agent
- Defined in:
- lib/jiji/agent/agent.rb
Overview
一定期間ごとに通知を受け取るエージェントの基底クラス。
Instance Attribute Summary
Attributes included from Agent
Instance Method Summary collapse
-
#initialize(period = 10) ⇒ PeriodicallyAgent
constructor
A new instance of PeriodicallyAgent.
- #next_period_rates(rates) ⇒ Object
- #next_rates(rates) ⇒ Object
- #property_infos ⇒ Object
Methods included from Agent
#description, #init, #properties, #properties=
Constructor Details
#initialize(period = 10) ⇒ PeriodicallyAgent
Returns a new instance of PeriodicallyAgent.
69 70 71 72 73 |
# File 'lib/jiji/agent/agent.rb', line 69 def initialize( period=10 ) @period = period @start = nil @rates = nil end |
Instance Method Details
#next_period_rates(rates) ⇒ Object
89 90 |
# File 'lib/jiji/agent/agent.rb', line 89 def next_period_rates( rates ) end |
#next_rates(rates) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/jiji/agent/agent.rb', line 74 def next_rates( rates ) @rates = PeriodicallyRates.new( rates.pair_infos ) unless @rates now = rates.time @start = now unless @start @rates << rates if ( now - @start ) > @period*60 next_period_rates( @rates ) @rates = PeriodicallyRates.new( rates.pair_infos ) @rates.start_time = now @start = now end end |