Class: JIJI::Dao::RateDao::PairBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/jiji/dao/rate_dao.rb

Instance Method Summary collapse

Constructor Details

#initializePairBuffer

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

#nextObject



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

Returns:

  • (Boolean)


137
138
139
# File 'lib/jiji/dao/rate_dao.rb', line 137

def next?
  @buff.length > 0
end