Class: Geoffrey::Template

Inherits:
Object
  • Object
show all
Includes:
FileHelper
Defined in:
lib/geoffrey/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileHelper

#extract_filename, #remove_extension

Constructor Details

#initialize(file) ⇒ Template

Returns a new instance of Template.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/geoffrey/template.rb', line 13

def initialize(file)
  @file = file
  @package = Geoffrey::Package.new
  set_name_from_file
  case File.extname(file)
  when '.rb'
    package.instance_eval open(file).read
  when '.json'
    load_attributes_from_json
  end
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



11
12
13
# File 'lib/geoffrey/template.rb', line 11

def file
  @file
end

#packageObject

Returns the value of attribute package.



11
12
13
# File 'lib/geoffrey/template.rb', line 11

def package
  @package
end