class Yapt::View

Public Class Methods

extract_display_config(args) click to toggle source
# File lib/yapt/view.rb, line 6
def self.extract_display_config(args)
  display = args.detect {|a| a =~ /\Av(iew)?[=:]/ }
  args.delete(display)
  display ? display.split(/[=:]/).last : nil
end
new(stories) click to toggle source
# File lib/yapt/view.rb, line 12
def initialize(stories)
  @stories = stories
end

Public Instance Methods

display(template_name) click to toggle source
# File lib/yapt/view.rb, line 16
def display(template_name)
  template_path = "#{template_dir}/#{template_name}.erb"
  if File.exists?(template_path)
    template = IO.read template_path
    ERB.new(template, 0, '-').result(binding)
  else
    raise "#{template_path} missing!"
  end
end
template_dir() click to toggle source
# File lib/yapt/view.rb, line 26
def template_dir
  "#{File.dirname(__FILE__)}/templates"
end