Class: Loincloth::BlockParser

Inherits:
Object
  • Object
show all
Defined in:
lib/loincloth/block_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ BlockParser

Returns a new instance of BlockParser.



3
4
5
# File 'lib/loincloth/block_parser.rb', line 3

def initialize(stream)
  @stream = stream
end

Instance Method Details

#each_block(&action) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/loincloth/block_parser.rb', line 6

def each_block(&action)
  buffer = []
  @stream.each{ |line|
    if is_block_separator(line)
      do_action(action, buffer)
      buffer = []
    else
      buffer << line.chomp
    end
  }
  do_action(action, buffer)
end