Class: KeepYourHead::Preferences

Inherits:
Object
  • Object
show all
Defined in:
lib/Keepyourhead/Preferences.rb

Constant Summary collapse

Filename =
Resources::user "Preferences.yaml"

Instance Method Summary collapse

Constructor Details

#initializePreferences

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

#loadObject



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

#writeBackObject



36
37
38
39
40
# File 'lib/Keepyourhead/Preferences.rb', line 36

def writeBack
	::File.open( Filename, "w" ) { |file|
		YAML::dump(@data, file)
	}
end