Class: Controlio::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/controlio/settings.rb

Constant Summary collapse

API_ROOT =
ENV['API_ROOT'] || 'http://ym-remote-control-web.herokuapp.com'
SETTINGS_FILE =
File.expand_path "~/.controlio.json"

Instance Method Summary collapse

Constructor Details

#initializeSettings

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