Class: ConfigLoader::Yaml

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, root = nil) ⇒ Yaml

will try root element if such exists



8
9
10
11
12
13
14
15
16
# File 'lib/config_loader/yaml.rb', line 8

def initialize file_path, root = nil
	@file_path = file_path
	@path 		 = File.dirname file_path
	@file_name = File.basename file_path
	@ext 			 = file_name.split(/(ya?ml$)/).last
	@root 		 = (root || file_name.split('.').first).to_s
	@root 		 = nil unless mashie.send(@root)
	@mashie 	 = mashie.send(@root) if @root
end

Instance Attribute Details

#extObject (readonly)

Returns the value of attribute ext.



5
6
7
# File 'lib/config_loader/yaml.rb', line 5

def ext
  @ext
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



5
6
7
# File 'lib/config_loader/yaml.rb', line 5

def file_name
  @file_name
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



5
6
7
# File 'lib/config_loader/yaml.rb', line 5

def file_path
  @file_path
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/config_loader/yaml.rb', line 5

def path
  @path
end

#rootObject (readonly)

Returns the value of attribute root.



5
6
7
# File 'lib/config_loader/yaml.rb', line 5

def root
  @root
end

Instance Method Details

#as_hashObject



18
19
20
# File 'lib/config_loader/yaml.rb', line 18

def as_hash
	@as_hash ||= mashie
end

#as_yamlObject



22
23
24
# File 'lib/config_loader/yaml.rb', line 22

def as_yaml
	@as_yaml ||= ::YAML::load File.open(config_file_path)
end