Sha256: 357e36a47eb91ce9f3e0a04758f9edc9f3a1734de1e54ea3d596f72132feed43

Contents?: true

Size: 769 Bytes

Versions: 3

Compression:

Stored size: 769 Bytes

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.1.5 lib/vedeu/output/view.rb
vedeu-0.1.4 lib/vedeu/output/view.rb
vedeu-0.1.3 lib/vedeu/output/view.rb