Class: Template

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Template

Returns a new instance of Template.



12
13
14
15
# File 'lib/template.rb', line 12

def initialize(file_path)
  @file_path = file_path
  @contents = File.open(@file_path, "rb").read
end

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



6
7
8
# File 'lib/template.rb', line 6

def contents
  @contents
end

#file_pathObject

Returns the value of attribute file_path.



6
7
8
# File 'lib/template.rb', line 6

def file_path
  @file_path
end

Class Method Details

.allObject



8
9
10
# File 'lib/template.rb', line 8

def self.all
  Dir.glob("lib/templates/*").collect{|t| Template.new(t)}
end

Instance Method Details

#variablesObject



17
18
19
# File 'lib/template.rb', line 17

def variables
  self.contents.scan(/(\@[a-z]+[0-9a-z_]*)/i).uniq
end