Class: JIJI::PeriodicallyRate
- Inherits:
-
Object
- Object
- JIJI::PeriodicallyRate
- Includes:
- Dao::TimedData, Util::Model
- Defined in:
- lib/jiji/models.rb
Overview
一定期間のレート
bid,ask,sell_swap,buy_swapは四本値(JIJI::PeriodicallyValue)で保持される。
Instance Attribute Summary collapse
-
#ask ⇒ Object
readonly
Returns the value of attribute ask.
-
#bid ⇒ Object
readonly
Returns the value of attribute bid.
-
#buy_swap ⇒ Object
readonly
Returns the value of attribute buy_swap.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#sell_swap ⇒ Object
readonly
Returns the value of attribute sell_swap.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
- #<<(rate) ⇒ Object
-
#initialize(list = []) ⇒ PeriodicallyRate
constructor
A new instance of PeriodicallyRate.
- #time ⇒ Object
- #time=(t) ⇒ Object
-
#values ⇒ Object
値を配列で取得する.
-
#values=(values) ⇒ Object
値を配列で設定する.
Methods included from Util::Model
Constructor Details
#initialize(list = []) ⇒ PeriodicallyRate
Returns a new instance of PeriodicallyRate.
94 95 96 97 98 99 100 101 102 |
# File 'lib/jiji/models.rb', line 94 def initialize( list=[] ) @bid = PeriodicallyValue.new @ask = PeriodicallyValue.new @sell_swap = PeriodicallyValue.new @buy_swap = PeriodicallyValue.new list.each { |item| self << item } end |
Instance Attribute Details
#ask ⇒ Object (readonly)
Returns the value of attribute ask.
131 132 133 |
# File 'lib/jiji/models.rb', line 131 def ask @ask end |
#bid ⇒ Object (readonly)
Returns the value of attribute bid.
131 132 133 |
# File 'lib/jiji/models.rb', line 131 def bid @bid end |
#buy_swap ⇒ Object (readonly)
Returns the value of attribute buy_swap.
131 132 133 |
# File 'lib/jiji/models.rb', line 131 def buy_swap @buy_swap end |
#end_time ⇒ Object
Returns the value of attribute end_time.
133 134 135 |
# File 'lib/jiji/models.rb', line 133 def end_time @end_time end |
#sell_swap ⇒ Object (readonly)
Returns the value of attribute sell_swap.
131 132 133 |
# File 'lib/jiji/models.rb', line 131 def sell_swap @sell_swap end |
#start_time ⇒ Object
Returns the value of attribute start_time.
132 133 134 |
# File 'lib/jiji/models.rb', line 132 def start_time @start_time end |
Instance Method Details
#<<(rate) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/jiji/models.rb', line 103 def <<( rate ) @bid << rate.bid @ask << rate.ask @sell_swap << rate.sell_swap @buy_swap << rate.buy_swap @start_time = rate.time unless @start_time @end_time = rate.time end |
#time ⇒ Object
125 126 127 |
# File 'lib/jiji/models.rb', line 125 def time @end_time end |
#time=(t) ⇒ Object
128 129 130 |
# File 'lib/jiji/models.rb', line 128 def time=(t) @end_time = t end |
#values ⇒ Object
値を配列で取得する
112 113 114 115 |
# File 'lib/jiji/models.rb', line 112 def values bid.values + ask.values + sell_swap.values + buy_swap.values \ + [@start_time.to_i, @end_time.to_i] end |
#values=(values) ⇒ Object
値を配列で設定する
117 118 119 120 121 122 123 124 |
# File 'lib/jiji/models.rb', line 117 def values=(values) @bid.values = values[0..3] @ask.values = values[4..7] @sell_swap.values = values[8..11] @buy_swap.values = values[12..15] @start_time = Time.at(values[16].to_i) @end_time = Time.at(values[17].to_i) end |