Sha256: c698a210e6a7dcf2f437638fd6a0079c187bb31b00b87d8e797963c0ad46b4b9

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'vedeu/models/composition'
require 'vedeu/output/erb_parser'
require 'vedeu/output/raw_parser'
require 'vedeu/output/json_parser'
require 'vedeu/output/menu_parser'
require 'vedeu/output/raw_parser'

module Vedeu
  class View
    def self.render(type, output)
      new(type, output).render
    end

    def initialize(type, output)
      @type, @output = type, output
    end

    def render
      Composition.enqueue(parsed_output)
    end

    private

    attr_reader :type, :output

    def parsed_output
      @parsed ||= parser.parse(output)
    end

    def parser
      {
        erb:     ERBParser,
        json:    JSONParser,
        hash:    RawParser,
        menu:    MenuParser,
        raw:     RawParser,
      }.fetch(type)
    end
  end
end

# ERBParser:  { :interface, :path, :object }
# RawParser: { 'interface_name' => String|Array }
#             { :interface_name  => String|Array }
# JSONParser: output (string which is converted into a hash)
# MenuParser: ['interface_name', Vedeu::Menu instance]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.2 lib/vedeu/output/view.rb