Class: Controlio::Settings
- Inherits:
-
Object
- Object
- Controlio::Settings
- Defined in:
- lib/controlio/settings.rb
Constant Summary collapse
- API_ROOT =
ENV['API_ROOT'] || 'http://ym-remote-control-web.herokuapp.com'
- SETTINGS_FILE =
File. "~/.controlio.json"
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #set(key, value) ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
10 11 12 |
# File 'lib/controlio/settings.rb', line 10 def initialize @settings = (begin JSON.parse File.read(SETTINGS_FILE) rescue create_new_settings end).with_indifferent_access end |
Instance Method Details
#get(key) ⇒ Object
14 15 16 |
# File 'lib/controlio/settings.rb', line 14 def get(key) @settings[key] end |
#set(key, value) ⇒ Object
18 19 20 21 |
# File 'lib/controlio/settings.rb', line 18 def set(key, value) @settings[key] = value File.write SETTINGS_FILE, settings.to_json end |