Class: Isaac::Config::Data
- Inherits:
-
Object
- Object
- Isaac::Config::Data
- Defined in:
- lib/isaac/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#config_filename ⇒ Object
Returns the value of attribute config_filename.
Class Method Summary collapse
Instance Method Summary collapse
- #config_dir ⇒ Object
- #default_config_file ⇒ Object
-
#initialize(filename = nil) ⇒ Data
constructor
A new instance of Data.
- #networks ⇒ Object
- #read_config(filename = nil) ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(filename = nil) ⇒ Data
Returns a new instance of Data.
68 69 70 71 |
# File 'lib/isaac/config.rb', line 68 def initialize(filename=nil) self.config_filename = filename || default_config_file @config = read_config(config_filename) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
66 67 68 |
# File 'lib/isaac/config.rb', line 66 def config @config end |
#config_filename ⇒ Object
Returns the value of attribute config_filename.
66 67 68 |
# File 'lib/isaac/config.rb', line 66 def config_filename @config_filename end |
Class Method Details
Instance Method Details
#config_dir ⇒ Object
73 74 75 |
# File 'lib/isaac/config.rb', line 73 def config_dir File.exist?('config') && File.directory?('config') ? './config' : '.' end |
#default_config_file ⇒ Object
77 78 79 |
# File 'lib/isaac/config.rb', line 77 def default_config_file File.join(config_dir, "config.yml") end |
#networks ⇒ Object
81 82 83 |
# File 'lib/isaac/config.rb', line 81 def networks config.keys end |
#read_config(filename = nil) ⇒ Object
85 86 87 88 89 |
# File 'lib/isaac/config.rb', line 85 def read_config(filename=nil) self.config_filename = filename if filename Isaac.logger.debug "Loading config from #{config_filename}" YAML.load_file(config_filename) rescue {"default" => {}} end |
#to_yaml ⇒ Object
91 92 93 |
# File 'lib/isaac/config.rb', line 91 def to_yaml config.to_yaml end |