Class: Packtory::Packer::TemplateFile

Inherits:
Object
  • Object
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.



422
423
424
425
426
# File 'lib/packtory/packer.rb', line 422

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 (private)



443
444
445
446
447
448
449
450
451
452
453
# File 'lib/packtory/packer.rb', line 443

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



437
438
439
# File 'lib/packtory/packer.rb', line 437

def concat(str)
  @output_buffer << str
end

#evaluate!Object



428
429
430
431
432
433
# File 'lib/packtory/packer.rb', line 428

def evaluate!
  erb = ERB.new(File.read(@file_path), nil, '-', '@output_buffer')
  File.write(@file_path, erb.result(binding))

  @file_path
end

#packerObject



435
# File 'lib/packtory/packer.rb', line 435

def packer; @packer; end