Class: Packtory::Packer::TemplateFile
- Inherits:
-
Object
- Object
- Packtory::Packer::TemplateFile
show all
- Defined in:
- lib/packtory/packer.rb
Instance Method Summary
collapse
Constructor Details
#initialize(packer, file_path, tvalues) ⇒ TemplateFile
Returns a new instance of TemplateFile.
427
428
429
430
431
|
# File 'lib/packtory/packer.rb', line 427
def initialize(packer, file_path, tvalues)
@packer = packer
@file_path = file_path
@tvalues = tvalues
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(k, *args) ⇒ Object
448
449
450
451
452
453
454
455
456
457
458
|
# File 'lib/packtory/packer.rb', line 448
def method_missing(k, *args)
if @tvalues.nil?
super
elsif @tvalues.include?(k.to_s)
@tvalues[k.to_s]
elsif @tvalues.include?(k)
@tvalues[k]
else
super
end
end
|
Instance Method Details
#concat(str) ⇒ Object
442
443
444
|
# File 'lib/packtory/packer.rb', line 442
def concat(str)
@output_buffer << str
end
|
#evaluate! ⇒ Object
433
434
435
436
437
438
|
# File 'lib/packtory/packer.rb', line 433
def evaluate!
erb = ERB.new(File.read(@file_path), nil, '-', '@output_buffer')
File.write(@file_path, erb.result(binding))
@file_path
end
|
#packer ⇒ Object
440
|
# File 'lib/packtory/packer.rb', line 440
def packer; @packer; end
|