Class: Kymera::Config
- Inherits:
-
Object
- Object
- Kymera::Config
- Defined in:
- lib/kymera/config/config.rb
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
The constructor reads in the config.yaml file, converts it into a hash and then defines methods on this class based on the different sections.
- #to_s ⇒ Object
-
#update ⇒ Object
This takes any changes that were made to the different sections and updates the config.yaml file (more to the point, overrides the old file and replaces the entire file with the new values).
Constructor Details
#initialize ⇒ Config
The constructor reads in the config.yaml file, converts it into a hash and then defines methods on this class based on the different sections
7 8 9 10 11 12 13 14 15 |
# File 'lib/kymera/config/config.rb', line 7 def initialize yaml_file = File.open(File.join(Dir.pwd, '/kymera_config.yaml'), 'r+') yaml_file.rewind @config_options = YAML.load(yaml_file.read) @config_options.each do |key, value| define_singleton_method(key){value} end yaml_file.close end |
Instance Method Details
#to_s ⇒ Object
30 31 32 |
# File 'lib/kymera/config/config.rb', line 30 def to_s @config_options.to_yaml end |
#update ⇒ Object
This takes any changes that were made to the different sections and updates the config.yaml file (more to the point, overrides the old file and replaces the entire file with the new values)
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kymera/config/config.rb', line 19 def update yaml_file = File.open(File.join(Dir.pwd, '/kymera_config.yaml'), 'w+') @config_options.to_yaml.split('\n').each do |line| yaml_file.write(line) end yaml_file.rewind str = yaml_file.read yaml_file.close str end |