Class: JIJI::PeriodicallyAgent

Inherits:
Object
  • Object
show all
Includes:
Agent
Defined in:
lib/jiji/agent/agent.rb

Overview

一定期間ごとに通知を受け取るエージェントの基底クラス。

Instance Attribute Summary

Attributes included from Agent

#logger, #operator, #output

Instance Method Summary collapse

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

#property_infosObject



86
87
88
# File 'lib/jiji/agent/agent.rb', line 86

def property_infos
  super() + [Property.new(:period, "レートの通知を受け取る間隔(分)", 10, :number)]
end