Class: Lablr::Template::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lablr/template.rb', line 8

def initialize(options = {})
  #@erb = options[:erb]          ||= nil
  options[:name]    ||= "avery_5163"
  options[:content] ||= "No Content Set"
  options[:style]   ||= TemplateStyle.new
  
  @name                 = options[:name]              
  @content              = options[:content]          
  @style                = options[:style] 
  
  template_file = File.join(Lablr.GEM_ROOT, "assets", "templates",  "_" + (@name.to_s) + ".erb")
  template_content = File.exists?(template_file) ? File.read(template_file) : "Template Not Found: #{template_file}"
  
  @erb = ::ERB.new(template_content)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/lablr/template.rb', line 4

def content
  @content
end

#erbObject

Returns the value of attribute erb.



4
5
6
# File 'lib/lablr/template.rb', line 4

def erb
  @erb
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/lablr/template.rb', line 4

def name
  @name
end

#styleObject

Returns the value of attribute style.



4
5
6
# File 'lib/lablr/template.rb', line 4

def style
  @style
end

Instance Method Details

#getBindingObject

make binding accessible to pass into erb



24
25
26
# File 'lib/lablr/template.rb', line 24

def getBinding # make binding accessible to pass into erb
  return binding
end