Class: PostRunner::RuntimeConfig
- Inherits:
-
Object
- Object
- PostRunner::RuntimeConfig
- Defined in:
- lib/postrunner/RuntimeConfig.rb
Overview
Simple class to manage runtime configuration options which are persisted in a YAML file.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Shortcut for get_option.
-
#get_option(name) ⇒ Object
Get a config option value.
-
#initialize(dir) ⇒ RuntimeConfig
constructor
Create a new RC object.
-
#set_option(name, value) ⇒ Object
Set a config option and update the RC file.
Constructor Details
#initialize(dir) ⇒ RuntimeConfig
Create a new RC object.
24 25 26 27 28 29 30 31 32 |
# File 'lib/postrunner/RuntimeConfig.rb', line 24 def initialize(dir) @options = { :unit_system => :metric, :import_dir => nil } @config_file = File.join(dir, 'config.yml') if File.exist?(@config_file) end |
Instance Method Details
#[](name) ⇒ Object
Shortcut for get_option.
37 38 39 |
# File 'lib/postrunner/RuntimeConfig.rb', line 37 def [](name) get_option(name) end |
#get_option(name) ⇒ Object
Get a config option value.
44 45 46 |
# File 'lib/postrunner/RuntimeConfig.rb', line 44 def get_option(name) @options[name] end |
#set_option(name, value) ⇒ Object
Set a config option and update the RC file.
51 52 53 54 |
# File 'lib/postrunner/RuntimeConfig.rb', line 51 def set_option(name, value) @options[name] = value end |