Class: Rye::Tpl
- Inherits:
-
Object
- Object
- Rye::Tpl
- Defined in:
- lib/rye.rb
Instance Attribute Summary collapse
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
-
#result(binding) ⇒ Object
readonly
Returns the value of attribute result.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(src, basename = 'rye-template') ⇒ Tpl
constructor
A new instance of Tpl.
- #path ⇒ Object
- #result!(binding) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(src, basename = 'rye-template') ⇒ Tpl
287 288 289 290 291 |
# File 'lib/rye.rb', line 287 def initialize(src, basename='rye-template') @basename = basename src = src.to_s @src, @template = src, ERB.new(src) end |
Instance Attribute Details
#basename ⇒ Object (readonly)
Returns the value of attribute basename.
286 287 288 |
# File 'lib/rye.rb', line 286 def basename @basename end |
#result(binding) ⇒ Object (readonly)
Returns the value of attribute result.
286 287 288 |
# File 'lib/rye.rb', line 286 def result @result end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
286 287 288 |
# File 'lib/rye.rb', line 286 def src @src end |
Instance Method Details
#delete ⇒ Object
300 301 302 |
# File 'lib/rye.rb', line 300 def delete File.delete(@tf.path) if File.exists?(@tf.path) end |
#path ⇒ Object
292 293 294 295 296 297 298 299 |
# File 'lib/rye.rb', line 292 def path if @tf.nil? @tf = Tempfile.new basename @tf.write @result @tf.close end @tf.path end |
#result!(binding) ⇒ Object
303 304 305 |
# File 'lib/rye.rb', line 303 def result!(binding) @result = result(binding) end |
#to_s ⇒ Object
309 |
# File 'lib/rye.rb', line 309 def to_s() src end |