Class: Firefox::Prefs
- Inherits:
-
Fondue::HashClass
- Object
- Fondue::HashClass
- Firefox::Prefs
- Defined in:
- lib/firefox/prefs.rb
Constant Summary collapse
- BANNER =
default prefs.js banner
%{# Mozilla User Preferences /* Do not edit this file. * * If you make changes to this file while the application is running, * the changes will be overwritten when the application exits. * * To make a manual change to preferences, you can visit the URL about:config */ }
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#prefs ⇒ Object
Returns the value of attribute prefs.
-
#raw_prefs ⇒ Object
Returns the value of attribute raw_prefs.
Instance Method Summary collapse
-
#initialize(path_to_prefs) ⇒ Prefs
constructor
A new instance of Prefs.
- #stringified_prefs ⇒ Object
- #write!(write_path = '') ⇒ Object
Methods inherited from Fondue::HashClass
get_hash_attribute, hash_attribute, #method_missing, stringify
Constructor Details
#initialize(path_to_prefs) ⇒ Prefs
Returns a new instance of Prefs.
19 20 21 22 23 24 |
# File 'lib/firefox/prefs.rb', line 19 def initialize path_to_prefs @path = path_to_prefs @prefs = {} @types = {} parse_prefs! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Fondue::HashClass
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
17 18 19 |
# File 'lib/firefox/prefs.rb', line 17 def path @path end |
#prefs ⇒ Object
Returns the value of attribute prefs.
17 18 19 |
# File 'lib/firefox/prefs.rb', line 17 def prefs @prefs end |
#raw_prefs ⇒ Object
Returns the value of attribute raw_prefs.
17 18 19 |
# File 'lib/firefox/prefs.rb', line 17 def raw_prefs @raw_prefs end |
Instance Method Details
#stringified_prefs ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/firefox/prefs.rb', line 31 def stringified_prefs string = '' string << BANNER string << @prefs.map { |key,val| %{user_pref("#{key}", #{val.is_a?(String) ? %{"#{val}"} : val});} }.join("\n") string << "\n" end |
#write!(write_path = '') ⇒ Object
26 27 28 29 |
# File 'lib/firefox/prefs.rb', line 26 def write! write_path = '' path = write_path == '' ? @path : write_path File.open(path,'w') { |f| f.write(stringified_prefs) } end |