Sha256: 9b031e7816886173c04c71e9dc50a0f9ee48f772656f9735a806aa424cfe1fd6

Contents?: true

Size: 665 Bytes

Versions: 1

Compression:

Stored size: 665 Bytes

Contents

require 'erb'
require 'vedeu/support/helpers'
require 'vedeu/parsing/text_adaptor'

module Vedeu
  class ERBParser
    include Helpers

    def self.parse(object)
      new(object).parse
    end

    def initialize(object)
      @object = object
    end

    def parse
      {
        interfaces: [{ name: interface, lines: TextAdaptor.adapt(erb_output) }]
      }
    end

    private

    attr_reader :object

    def erb_output
      ERB.new(template, nil, '-').result(get_binding)
    end

    def interface
      object.interface
    end

    def template
      File.read(object.path)
    end

    def get_binding
      object.send(:binding)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.1 lib/vedeu/parsing/erb_parser.rb