Class: KeepYourHead::Preferences
- Inherits:
-
Object
- Object
- KeepYourHead::Preferences
- Defined in:
- lib/Keepyourhead/Preferences.rb
Constant Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#initialize ⇒ Preferences
constructor
A new instance of Preferences.
- #load ⇒ Object
- #writeBack ⇒ Object
Constructor Details
#initialize ⇒ Preferences
Returns a new instance of Preferences.
23 24 25 |
# File 'lib/Keepyourhead/Preferences.rb', line 23 def initialize load end |
Instance Method Details
#[](name) ⇒ Object
43 44 45 |
# File 'lib/Keepyourhead/Preferences.rb', line 43 def []( name ) @data[name] end |
#[]=(name, value) ⇒ Object
46 47 48 |
# File 'lib/Keepyourhead/Preferences.rb', line 46 def []=( name, value ) @data[name] = value end |
#load ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/Keepyourhead/Preferences.rb', line 27 def load begin @data = YAML::load_file( Filename ) rescue @data = {} print "no Preferences not found" end end |
#writeBack ⇒ Object
36 37 38 39 40 |
# File 'lib/Keepyourhead/Preferences.rb', line 36 def writeBack ::File.open( Filename, "w" ) { |file| YAML::dump(@data, file) } end |