Class: H2o::FileLoader

Inherits:
Object show all
Defined in:
lib/h2o/file_loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileLoader

Returns a new instance of FileLoader.



5
6
7
8
9
# File 'lib/h2o/file_loader.rb', line 5

def initialize(path)
  raise "Search path not found" unless File.exist?(path)
  
  self.path = Pathname.new(path)
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/h2o/file_loader.rb', line 3

def path
  @path
end

Instance Method Details

#exist?(file) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/h2o/file_loader.rb', line 16

def exist?(file)
  File.exist?(self.path + file)
end

#read(file) ⇒ Object



11
12
13
14
# File 'lib/h2o/file_loader.rb', line 11

def read(file)
  raise "Template not found" unless exist?(file)
  File.read(self.path + file)
end