Class: Ifconf::Parsers::RawBlock
- Inherits:
-
Object
- Object
- Ifconf::Parsers::RawBlock
- Defined in:
- lib/ifconf/parsers/raw_text_splitter.rb
Overview
Represents a single interface block of raw ifconfig text with its starting line number.
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#start_line ⇒ Object
readonly
Returns the value of attribute start_line.
Instance Method Summary collapse
- #body_lines ⇒ Object
- #empty? ⇒ Boolean
- #find_line(pattern) ⇒ Object
- #find_lines(pattern) ⇒ Object
- #header_line ⇒ Object
-
#initialize(start_line, lines) ⇒ RawBlock
constructor
A new instance of RawBlock.
- #raw ⇒ Object
Constructor Details
#initialize(start_line, lines) ⇒ RawBlock
Returns a new instance of RawBlock.
7 8 9 10 11 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 7 def initialize(start_line, lines) @start_line = start_line @lines = lines.freeze freeze end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
5 6 7 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 5 def lines @lines end |
#start_line ⇒ Object (readonly)
Returns the value of attribute start_line.
5 6 7 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 5 def start_line @start_line end |
Instance Method Details
#body_lines ⇒ Object
21 22 23 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 21 def body_lines @lines[1..] end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 33 def empty? @lines.empty? end |
#find_line(pattern) ⇒ Object
25 26 27 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 25 def find_line(pattern) @lines.find { |l| l.match?(pattern) } end |
#find_lines(pattern) ⇒ Object
29 30 31 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 29 def find_lines(pattern) @lines.grep(pattern) end |
#header_line ⇒ Object
17 18 19 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 17 def header_line @lines.first end |
#raw ⇒ Object
13 14 15 |
# File 'lib/ifconf/parsers/raw_text_splitter.rb', line 13 def raw @lines.join("\n") end |