class Myna
Attributes
value[RW]
load custom config file to ruby.
Example:
>> yaml = Myha.open_yaml(yaml_file_path) => Config file >> yaml.value => Hash >> yaml.get(:a,:b) => yaml.value['a']['b']
Public Class Methods
new()
click to toggle source
# File lib/myna.rb, line 15 def initialize end
open_yaml(path)
click to toggle source
# File lib/myna.rb, line 18 def self.open_yaml(path) # open yaml file and return a new MyHa instance of this file self.new.instance_eval do @value=YAML.load_file(path) return self end end
Public Instance Methods
get(*args)
click to toggle source
# File lib/myna.rb, line 26 def get(*args) # get value from @value, here can use nested, for example: # >> .get(:top_level, :second_level) # same way with the following: # >> value = @value['top_level', :second_level] # in yaml file, structure will be like this: ## :top_level ## :second_level: 'my_config' value=@value args.each{|arg| value=value[arg.to_s]} value end