Class: Idcf::Cli::Lib::Util::YmlConf
- Inherits:
-
Object
- Object
- Idcf::Cli::Lib::Util::YmlConf
- Defined in:
- lib/idcf/cli/lib/util/yml_conf.rb
Overview
yml conf
Class Attribute Summary collapse
-
.data ⇒ Object
readonly
Returns the value of attribute data.
Instance Attribute Summary collapse
-
#load_data ⇒ Object
readonly
Returns the value of attribute load_data.
Class Method Summary collapse
Instance Method Summary collapse
-
#find(path) ⇒ Object
get config value.
-
#initialize(*path) ⇒ YmlConf
constructor
initialize.
Constructor Details
#initialize(*path) ⇒ YmlConf
initialize
23 24 25 |
# File 'lib/idcf/cli/lib/util/yml_conf.rb', line 23 def initialize(*path) @load_data = YAML.load_file(path[0]) end |
Class Attribute Details
.data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/idcf/cli/lib/util/yml_conf.rb', line 11 def data @data end |
Instance Attribute Details
#load_data ⇒ Object (readonly)
Returns the value of attribute load_data.
8 9 10 |
# File 'lib/idcf/cli/lib/util/yml_conf.rb', line 8 def load_data @load_data end |
Class Method Details
.load(path) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/idcf/cli/lib/util/yml_conf.rb', line 12 def load(path) @data ||= {} return @data[path] unless @data[path].nil? @data[path] = name.constantize.new(path) @data[path] end |
Instance Method Details
#find(path) ⇒ Object
get config value
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/idcf/cli/lib/util/yml_conf.rb', line 33 def find(path) result = @load_data return result[path] if path.class == Symbol path.split('.').each do |name| result = result.fetch(name) end result rescue StandardError => _e raise Idcf::Cli::Error::CliError, "Error: could not read '#{path}'" end |