Class: JIJI::Service::RateService
- Inherits:
-
Object
- Object
- JIJI::Service::RateService
- Defined in:
- lib/jiji/service/rate_service.rb
Instance Attribute Summary collapse
-
#rate_dao ⇒ Object
Returns the value of attribute rate_dao.
Instance Method Summary collapse
-
#enable(pair, year, month) ⇒ Object
指定した月で利用可能な日の一覧を得る。.
-
#list(pair, scale, start_time, end_time) ⇒ Object
指定範囲のレートを取得する。.
-
#range(pair) ⇒ Object
利用可能なレートの開始日時/終了日時を得る。.
Instance Attribute Details
#rate_dao ⇒ Object
Returns the value of attribute rate_dao.
29 30 31 |
# File 'lib/jiji/service/rate_service.rb', line 29 def rate_dao @rate_dao end |
Instance Method Details
#enable(pair, year, month) ⇒ Object
指定した月で利用可能な日の一覧を得る。
23 24 25 26 27 |
# File 'lib/jiji/service/rate_service.rb', line 23 def enable( pair, year, month ) dao = @rate_dao.dao( pair ) list = dao.list_data_files( :raw, "#{year}-#{sprintf("%02d", month)}" ) list.map {|d| d[-2,2] } end |
#list(pair, scale, start_time, end_time) ⇒ Object
指定範囲のレートを取得する。
6 7 8 9 10 11 12 13 |
# File 'lib/jiji/service/rate_service.rb', line 6 def list( pair, scale, start_time, end_time ) buff = [] @rate_dao.each( scale, pair.to_sym, Time.at(start_time), Time.at(end_time) ) {|data| buff << [data[0].to_f, data[1].to_f, data[2].to_f, data[3].to_f,data[16].to_i, data[17].to_i] } return buff end |
#range(pair) ⇒ Object
利用可能なレートの開始日時/終了日時を得る。
16 17 18 19 20 |
# File 'lib/jiji/service/rate_service.rb', line 16 def range( pair ) dao = @rate_dao.dao( pair ) { :first=>dao.first_time(:raw).to_i, :last=>dao.last_time(:raw).to_i } end |