Class: Bonsai::Template

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

Defined Under Namespace

Classes: NotFound

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Template

Returns a new instance of Template.



27
28
29
# File 'lib/bonsai/template.rb', line 27

def initialize(path)
  @path = path
end

Class Attribute Details

.pathObject

Returns the value of attribute path.



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

def path
  @path
end

Instance Attribute Details

#pathObject (readonly)

Instance methods



25
26
27
# File 'lib/bonsai/template.rb', line 25

def path
  @path
end

Class Method Details

.find(name) ⇒ Object



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

def find(name)
  disk_path = Dir["#{path}/#{name}.*"]
  
  if disk_path.any? 
    new disk_path.first
  else
    raise NotFound, "template '#{name}' not found at #{path}"
  end
end