Class: Quickpress::Options
- Inherits:
-
Object
- Object
- Quickpress::Options
- Defined in:
- lib/quickpress/options.rb
Overview
Hash that holds global program’s settings.
There should be only one instalce of it.
Instance Method Summary collapse
- #[](label) ⇒ Object
- #[]=(label, val) ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
-
#merge!(other_hash) ⇒ Object
To add settings saved on other hash.
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
9 10 11 |
# File 'lib/quickpress/options.rb', line 9 def initialize @values = {} end |
Instance Method Details
#[](label) ⇒ Object
13 14 15 |
# File 'lib/quickpress/options.rb', line 13 def [] label @values[label] end |
#[]=(label, val) ⇒ Object
17 18 19 |
# File 'lib/quickpress/options.rb', line 17 def []=(label, val) @values[label] = val end |
#merge!(other_hash) ⇒ Object
Note:
I don’t use Hash#merge because Thor’s argument list creates a Hash with darn Strings as keys. I want symbols, dammit!
To add settings saved on other hash.
27 28 29 30 31 |
# File 'lib/quickpress/options.rb', line 27 def merge! other_hash other_hash.each do |key, val| @values[key.to_sym] = val end end |