Class: ConfigLoader::Yaml
- Inherits:
-
Object
- Object
- ConfigLoader::Yaml
- Defined in:
- lib/config_loader/yaml.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #as_hash ⇒ Object
- #as_yaml ⇒ Object
-
#initialize(file_path, root = nil) ⇒ Yaml
constructor
will try root element if such exists.
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
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
5 6 7 |
# File 'lib/config_loader/yaml.rb', line 5 def ext @ext end |
#file_name ⇒ Object (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_path ⇒ Object (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 |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/config_loader/yaml.rb', line 5 def path @path end |
#root ⇒ Object (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_hash ⇒ Object
18 19 20 |
# File 'lib/config_loader/yaml.rb', line 18 def as_hash @as_hash ||= mashie end |
#as_yaml ⇒ Object
22 23 24 |
# File 'lib/config_loader/yaml.rb', line 22 def as_yaml @as_yaml ||= ::YAML::load File.open(config_file_path) end |