Class: Preferences
- Inherits:
-
Object
- Object
- Preferences
- Defined in:
- lib/models/preferences.rb
Constant Summary collapse
- @@home_dir =
ENV['HOME']
- @@defaults =
{ editor: 'vim', notes_dir: "#{@@home_dir}/Notes" }
- @@prefs_file =
"#{@@home_dir}/.peter-notes.yml"
Instance Attribute Summary collapse
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#notes_dir ⇒ Object
readonly
Returns the value of attribute notes_dir.
-
#preferences ⇒ Object
readonly
Returns the value of attribute preferences.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(prefs = nil) ⇒ Preferences
constructor
A new instance of Preferences.
Constructor Details
#initialize(prefs = nil) ⇒ Preferences
25 26 27 28 29 30 |
# File 'lib/models/preferences.rb', line 25 def initialize(prefs=nil) @preferences = prefs || load_preferences @preferences[:notes_dir] = File.(@preferences[:notes_dir]) @editor = @preferences[:editor] @notes_dir = @preferences[:notes_dir] end |
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
4 5 6 |
# File 'lib/models/preferences.rb', line 4 def editor @editor end |
#notes_dir ⇒ Object (readonly)
Returns the value of attribute notes_dir.
4 5 6 |
# File 'lib/models/preferences.rb', line 4 def notes_dir @notes_dir end |
#preferences ⇒ Object (readonly)
Returns the value of attribute preferences.
4 5 6 |
# File 'lib/models/preferences.rb', line 4 def preferences @preferences end |
Class Method Details
.defaults ⇒ Object
13 14 15 |
# File 'lib/models/preferences.rb', line 13 def self.defaults @@defaults end |
.defaults_yaml ⇒ Object
21 22 23 |
# File 'lib/models/preferences.rb', line 21 def self.defaults_yaml @@defaults.to_yaml end |
.prefs_file ⇒ Object
17 18 19 |
# File 'lib/models/preferences.rb', line 17 def self.prefs_file @@prefs_file end |
.write_yaml_defaults ⇒ Object
32 33 34 |
# File 'lib/models/preferences.rb', line 32 def self.write_yaml_defaults File.write(@@prefs_file, self.defaults_yaml) end |