Class: Yapt::View

Inherits:
Object
  • Object
show all
Defined in:
lib/yapt/view.rb

Direct Known Subclasses

GitView

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stories) ⇒ View

Returns a new instance of View.



12
13
14
# File 'lib/yapt/view.rb', line 12

def initialize(stories)
  @stories = stories
end

Class Method Details

.extract_display_config(args) ⇒ Object



6
7
8
9
10
# 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

Instance Method Details

#display(template_name) ⇒ Object



16
17
18
19
20
21
22
23
24
# 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_dirObject



26
27
28
# File 'lib/yapt/view.rb', line 26

def template_dir
  "#{File.dirname(__FILE__)}/templates"
end