Class: Vedeu::HashParser

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/parsing/hash_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = {}) ⇒ HashParser

Returns a new instance of HashParser.



43
44
45
# File 'lib/vedeu/parsing/hash_parser.rb', line 43

def initialize(output = {})
  @output = output
end

Class Method Details

.parse(output = {}) ⇒ Hash

Convert a hash into a collection of interfaces.

Parameters:

  • output (Hash) (defaults to: {})

    a collection of interface pairs of the format:

    interface_1: "A block of text containing\n" \
                 "new line characters.\n",
    interface_2: "Some content destined for the " \
                 "other interface.\n"
    

    becomes:

    {

    interfaces: [
      {
        name:  'interface_1',
        lines: [{
            streams: { text: "A block of text containing" }
          }, {
            streams: { text: "new line characters." }
        }]
      }, {
        name:  'interface_2',
        lines: [{
            streams: { text: "Some content destined for the " \
                             "other interface." }
        }]
      }
    ]
    

    }

Returns:

  • (Hash)


39
40
41
# File 'lib/vedeu/parsing/hash_parser.rb', line 39

def self.parse(output = {})
  new(output).parse
end

Instance Method Details

#parseObject



47
48
49
# File 'lib/vedeu/parsing/hash_parser.rb', line 47

def parse
  { interfaces: interfaces }
end