Class: Quickpress::Options

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeOptions

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