class Omniboard::Renderer

Attributes

columns[RW]

Public Class Methods

new() click to toggle source
# File lib/omniboard/renderer.rb, line 4
def initialize()
  @columns = []
  @current_column = nil
  @current_group = nil
end

Public Instance Methods

add_column(*col) click to toggle source

Add one or more columns to our array of columns.

# File lib/omniboard/renderer.rb, line 11
def add_column(*col)
        @columns += col
end
postamble() click to toggle source
# File lib/omniboard/renderer.rb, line 24
def postamble
        ERB.new(template "postamble").result(binding)
end
preamble() click to toggle source
# File lib/omniboard/renderer.rb, line 20
def preamble
        ERB.new(template "preamble").result(binding)
end
render_column(column) click to toggle source
# File lib/omniboard/renderer.rb, line 28
def render_column(column)
        ERB.new(template("column")).result(binding)
end
render_project(project) click to toggle source
# File lib/omniboard/renderer.rb, line 32
def render_project(project)
        ERB.new(template("project")).result(binding)
end
template(template_name) click to toggle source

Fetch a template from the templates folder

# File lib/omniboard/renderer.rb, line 37
def template(template_name)
        @templates ||= {}

        if !@templates.has_key?(template_name)
                template_file = template_name + ".erb"
                template_path = File.join(__dir__, "templates", template_file)
                raise(ArgumentError, "Attempting to find template #{template_file}, which does not exist.") unless File.exists?(template_path)

                @templates[template_name] = File.read(template_path)
        end
        @templates[template_name]
end
to_s() click to toggle source
# File lib/omniboard/renderer.rb, line 16
def to_s
        preamble + @columns.map{ |c| render_column(c) }.join("\n") + postamble
end