Class: JIJI::Dao::RateDao::PairBuffer
- Inherits:
-
Object
- Object
- JIJI::Dao::RateDao::PairBuffer
- Defined in:
- lib/jiji/dao/rate_dao.rb
Instance Method Summary collapse
- #add(pair, data) ⇒ Object
-
#initialize ⇒ PairBuffer
constructor
A new instance of PairBuffer.
- #next ⇒ Object
- #next? ⇒ Boolean
Constructor Details
#initialize ⇒ PairBuffer
Returns a new instance of PairBuffer.
129 130 131 |
# File 'lib/jiji/dao/rate_dao.rb', line 129 def initialize @buff = {} end |
Instance Method Details
#add(pair, data) ⇒ Object
132 133 134 135 136 |
# File 'lib/jiji/dao/rate_dao.rb', line 132 def add( pair, data ) time = data.last.to_i @buff[time] = {} unless @buff[time] @buff[time][pair.to_sym] = data end |
#next ⇒ Object
140 141 142 143 |
# File 'lib/jiji/dao/rate_dao.rb', line 140 def next keys = @buff.keys.sort! @buff.delete keys[0] end |
#next? ⇒ Boolean
137 138 139 |
# File 'lib/jiji/dao/rate_dao.rb', line 137 def next? @buff.length > 0 end |