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.
68 69 70 71 72 |
# File 'lib/jiji/agent/agent.rb', line 68 def initialize( period=10 ) @period = period @start = nil @rates = nil end |
Instance Method Details
#next_period_rates(rates) ⇒ Object
88 89 |
# File 'lib/jiji/agent/agent.rb', line 88 def next_period_rates( rates ) end |
#next_rates(rates) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/jiji/agent/agent.rb', line 73 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 |
#property_infos ⇒ Object
85 86 87 |
# File 'lib/jiji/agent/agent.rb', line 85 def property_infos super() + [Property.new(:period, "レートの通知を受け取る間隔(分)", 10, :number)] end |