Class: CompanionApi::Profile
- Inherits:
-
Object
- Object
- CompanionApi::Profile
- Defined in:
- lib/companion_api/profile.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#profile_name ⇒ Object
Returns the value of attribute profile_name.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(profile_name) ⇒ Profile
constructor
A new instance of Profile.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(profile_name) ⇒ Profile
Returns a new instance of Profile.
7 8 9 10 11 12 13 |
# File 'lib/companion_api/profile.rb', line 7 def initialize(profile_name) @file = File.join(CompanionApi.config.profile_directory, "#{profile_name}.json") FileUtils.mkdir_p(File.dirname(@file)) unless File.exist?(File.dirname(@file)) @settings = {} load end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'lib/companion_api/profile.rb', line 4 def file @file end |
#profile_name ⇒ Object
Returns the value of attribute profile_name.
3 4 5 |
# File 'lib/companion_api/profile.rb', line 3 def profile_name @profile_name end |
#settings ⇒ Object
Returns the value of attribute settings.
5 6 7 |
# File 'lib/companion_api/profile.rb', line 5 def settings @settings end |
Instance Method Details
#get(key) ⇒ Object
20 21 22 |
# File 'lib/companion_api/profile.rb', line 20 def get(key) @settings[key.to_sym] end |
#set(key, value) ⇒ Object
15 16 17 18 |
# File 'lib/companion_api/profile.rb', line 15 def set(key, value) @settings[key.to_sym] = value save! end |