Class: Conpar::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/conpar/document.rb

Class Method Summary collapse

Class Method Details

.parse(fw_config) ⇒ Array

Returns Array of Directive objects with which to perform logic

Parameters:

  • fw_config (String)

    Firewall configuration as string

Returns:

  • (Array)

    Array of Directive objects with which to perform logic


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/conpar/document.rb', line 7

def self.parse(fw_config)
  if fw_config.class != String
    raise ArgumentError, "fw_config must be string"
  end

  parsed = []
  lines = fw_config.split("\n")

  lines.each_with_index do |line, i|
    human_line = "#{i+1}".encode(line.encoding)
    parsed << Conpar.config.parser.new( line, line_number:human_line )
  end

  return parsed
end