Class: Ifconf::Parsers::BlockAccumulator
- Inherits:
-
Object
- Object
- Ifconf::Parsers::BlockAccumulator
- Defined in:
- lib/ifconf/parsers/raw_text_splitter.rb
Overview
Accumulates lines into RawBlock instances during ifconfig text splitting.
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize ⇒ BlockAccumulator
constructor
A new instance of BlockAccumulator.
- #process_line(line, idx) ⇒ Object
Constructor Details
#initialize ⇒ BlockAccumulator
Returns a new instance of BlockAccumulator.
57 58 59 60 61 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 57 def initialize @blocks = [] @current_lines = [] @current_start = nil end |
Instance Method Details
#finalize ⇒ Object
73 74 75 76 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 73 def finalize flush_current_block @blocks end |
#process_line(line, idx) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 63 def process_line(line, idx) if line.strip.empty? flush_current_block elsif /\A\S/.match?(line) start_new_block(line, idx) elsif !@current_lines.empty? @current_lines << line end end |