Class: JIJI::Dao::TimedDataIterator
- Defined in:
- lib/jiji/dao/timed_data_dao.rb
Overview
複数のCSVファイルのデータを順番に読み込む。
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(scale, start_time, end_time, dao) ⇒ TimedDataIterator
constructor
A new instance of TimedDataIterator.
- #next ⇒ Object
- #next? ⇒ Boolean
- #next_iterator ⇒ Object
Methods inherited from Iterator
Constructor Details
#initialize(scale, start_time, end_time, dao) ⇒ TimedDataIterator
Returns a new instance of TimedDataIterator.
197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/jiji/dao/timed_data_dao.rb', line 197 def initialize( scale, start_time, end_time, dao ) super() @dao = dao @start_time = start_time @end_time = end_time @scale = scale @current = start_time @current_date = Date.new( @current.year, @current.mon, \ TimedDataDao.dairy?(@scale) ? @current.day : 1 ) next_iterator end |
Instance Method Details
#close ⇒ Object
218 219 220 |
# File 'lib/jiji/dao/timed_data_dao.rb', line 218 def close @it.close if @it end |
#next ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/jiji/dao/timed_data_dao.rb', line 211 def next begin @it.next ensure next_iterator unless @it.next? end end |
#next? ⇒ Boolean
208 209 210 |
# File 'lib/jiji/dao/timed_data_dao.rb', line 208 def next? @it && @it.next? end |
#next_iterator ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/jiji/dao/timed_data_dao.rb', line 221 def next_iterator @it.close if @it @it = nil while ( @current.to_f <= @end_time.to_f ) begin it = @dao.each_dairy_data( @scale, @current, @start_time, @end_time) if it != nil && it.next? @it = it return else it.close end ensure @current_date = TimedDataDao.dairy?(@scale) ? @current_date+1 : @current_date >> 1 @current = Time.local(@current_date.year, @current_date.mon, @current_date.day) end end end |