Class: Deb822::Parser
- Inherits:
-
Object
- Object
- Deb822::Parser
- Defined in:
- lib/deb822/parser.rb
Overview
High-level parser for deb822 documents
Instance Method Summary collapse
- #each_paragraph {|last_par| ... } ⇒ Object (also: #paragraphs)
-
#initialize(input) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
Instance Method Details
#each_paragraph {|last_par| ... } ⇒ Object Also known as: paragraphs
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/deb822/parser.rb', line 11 def each_paragraph return to_enum(:each_paragraph) unless block_given? last_par = last_val = nil @scanner.each_line do |l| case l[0] when :paragraph_separator yield last_par if last_par last_par = last_val = nil when :comment next when :field last_par ||= Paragraph.new last_par[l[1]] = last_val = l[2] when :continuation last_val << "\n" unless last_val.end_with?("\n") last_val << l[1] else fail "BUG: unreachable code: #{l.inspect}" end end yield last_par if last_par end |