Class: IpTracker::Config
- Inherits:
-
Object
- Object
- IpTracker::Config
- Defined in:
- lib/ip_tracker/config.rb
Instance Attribute Summary collapse
-
#config_hash ⇒ Object
Returns the value of attribute config_hash.
-
#settings_path ⇒ Object
Returns the value of attribute settings_path.
Instance Method Summary collapse
- #host_token ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #pid ⇒ Object
- #update(attr, value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
6 7 8 9 |
# File 'lib/ip_tracker/config.rb', line 6 def initialize(={}) @settings_path = File.(IpTracker::DEFAULT_CONFIG_PATH) @config_hash = load_settings || {} end |
Instance Attribute Details
#config_hash ⇒ Object
Returns the value of attribute config_hash.
4 5 6 |
# File 'lib/ip_tracker/config.rb', line 4 def config_hash @config_hash end |
#settings_path ⇒ Object
Returns the value of attribute settings_path.
4 5 6 |
# File 'lib/ip_tracker/config.rb', line 4 def settings_path @settings_path end |
Instance Method Details
#host_token ⇒ Object
11 12 13 |
# File 'lib/ip_tracker/config.rb', line 11 def host_token config_hash["host_token"] || nil end |
#pid ⇒ Object
15 16 17 |
# File 'lib/ip_tracker/config.rb', line 15 def pid config_hash["pid"] || nil end |
#update(attr, value) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/ip_tracker/config.rb', line 19 def update(attr, value) config_hash[attr.to_s] = value File.open(settings_path, 'w') do |out| YAML.dump(config_hash, out) end end |