Class: AdHocTemplate::RecordReader::DefaultFormReader::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::DefaultFormReader::Reader

Instance Method Details

#read(line) ⇒ Object



344
345
346
347
348
349
350
351
352
353
354
# File 'lib/ad_hoc_template/record_reader.rb', line 344

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

#setup_stack(line) ⇒ Object



335
336
337
338
339
340
341
342
# File 'lib/ad_hoc_template/record_reader.rb', line 335

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, i[iteration block])
end