Class: Settings
- Inherits:
-
Object
- Object
- Settings
- Defined in:
- lib/rubysketch/solitaire/common/settings.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #clear ⇒ Object
-
#initialize(path) ⇒ Settings
constructor
A new instance of Settings.
- #to_json ⇒ Object
Constructor Details
#initialize(path) ⇒ Settings
Returns a new instance of Settings.
3 4 5 6 |
# File 'lib/rubysketch/solitaire/common/settings.rb', line 3 def initialize(path) @path = path or raise 'invalid path' @hash = load path end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/rubysketch/solitaire/common/settings.rb', line 21 def [](key) hash[key] end |
#[]=(key, value) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rubysketch/solitaire/common/settings.rb', line 13 def []=(key, value) if value != hash[key] hash[key] = value save @path end value end |
#clear ⇒ Object
8 9 10 11 |
# File 'lib/rubysketch/solitaire/common/settings.rb', line 8 def clear() hash.clear save @path end |
#to_json ⇒ Object
25 26 27 |
# File 'lib/rubysketch/solitaire/common/settings.rb', line 25 def to_json() hash.to_json end |