Class: Ifconf::Parsers::RawTextSplitter
- Inherits:
-
Object
- Object
- Ifconf::Parsers::RawTextSplitter
- Defined in:
- lib/ifconf/parsers/raw_text_splitter.rb
Overview
Splits raw ifconfig output into individual RawBlock instances, one per interface.
Class Method Summary collapse
Class Method Details
.detect_format(raw) ⇒ Object
50 51 52 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 50 def self.detect_format(raw) raw.include?("flags=") ? :linux : :bsd end |
.split(raw) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 40 def self.split(raw) return [] if raw.nil? || raw.strip.empty? accumulator = BlockAccumulator.new raw.split("\n", -1).each_with_index do |line, idx| accumulator.process_line(line, idx) end accumulator.finalize end |