Class: AdHocTemplate::RecordReader::BlockReader

Inherits:
Reader
  • Object
show all
Defined in:
lib/ad_hoc_template/record_reader.rb

Instance Method Summary collapse

Methods inherited from Reader

#initialize, #pop_stack, setup_reader

Constructor Details

This class inherits a constructor from AdHocTemplate::RecordReader::Reader

Instance Method Details

#read(line) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
# File 'lib/ad_hoc_template/record_reader.rb', line 230

def read(line)
  block_value = @stack.last_block_value
  case line
  when BLOCK_HEAD
    setup_new_block(line, String.new)
  when EMPTY_LINE
    block_value << line unless block_value.empty?
  else
    block_value << line
  end
end

#setup_stack(line) ⇒ Object



221
222
223
224
225
226
227
228
# File 'lib/ad_hoc_template/record_reader.rb', line 221

def setup_stack(line)
  case line
  when ITERATION_HEAD, BLOCK_HEAD
    @stack.remove_trailing_empty_lines_from_last_block!
    pop_stack
  end
  push_reader_if_match(line, [:iteration, :block])
end