class Disloku::Config::YamlConfig
Attributes
yaml[RW]
Public Class Methods
new(config, isFile = true)
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 9 def initialize(config, isFile = true) if (isFile) @yaml = YAML.load_file(config) else @yaml = config end end
Public Instance Methods
[](key)
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 33 def [](key) return self.get(key.split('.')) end
get(keys)
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 25 def get(keys) if (keys.empty?()) return self end current = keys.shift() return @yaml.has_key?(current) ? YamlConfig.new(@yaml[current], false).get(keys) : nil end
has?(key)
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 21 def has?(key) return self[key] != nil end
merge(base)
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 17 def merge(base) @yaml = base.yaml.recursive_merge(@yaml) end
to_s()
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 44 def to_s() return value().to_s() end
to_yaml()
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 48 def to_yaml() return @yaml.to_yaml() end
value()
click to toggle source
# File lib/disloku/config/YamlConfig.rb, line 37 def value() if (@yaml.kind_of?(Array)) return @yaml.map() { |item| YamlConfig.new(item, false) } end return @yaml end