Class: Picasa::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/picasa/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params) ⇒ Template


8
9
10
11
# File 'lib/picasa/template.rb', line 8

def initialize(name, params)
  @name   = name
  @params = params
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


6
7
8
# File 'lib/picasa/template.rb', line 6

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params


6
7
8
# File 'lib/picasa/template.rb', line 6

def params
  @params
end

Instance Method Details

#fileObject


13
14
15
# File 'lib/picasa/template.rb', line 13

def file
  @file ||= IO.read(::File.expand_path("../templates/#{name}.xml.erb", __FILE__))
end

#renderObject


21
22
23
# File 'lib/picasa/template.rb', line 21

def render
  ERB.new(file).result(struct.instance_eval { binding })
end

#structObject


17
18
19
# File 'lib/picasa/template.rb', line 17

def struct
  @struct ||= OpenStruct.new(params).extend(ERB::Util)
end