Class: Newgem::QuickTemplate
- Inherits:
-
Object
- Object
- Newgem::QuickTemplate
- Defined in:
- lib/newgem/quick_template.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #exec(b) ⇒ Object
-
#initialize(file) ⇒ QuickTemplate
constructor
A new instance of QuickTemplate.
Constructor Details
#initialize(file) ⇒ QuickTemplate
Returns a new instance of QuickTemplate.
6 7 8 9 |
# File 'lib/newgem/quick_template.rb', line 6 def initialize(file) @file = file @text = File.read(file) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/newgem/quick_template.rb', line 5 def args @args end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/newgem/quick_template.rb', line 5 def file @file end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/newgem/quick_template.rb', line 5 def text @text end |
Instance Method Details
#exec(b) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/newgem/quick_template.rb', line 10 def exec(b) begin # b = binding template = ERB.new(@text, 0, "%<>") result = template.result(b) # Chomp the trailing newline result.gsub(/\n$/,'') rescue NameError puts "Error found for #{file}" raise $! end end |