Class: Names
Instance Method Summary collapse
- #add(opts = {}) ⇒ Object
- #for(setting) ⇒ Object
-
#initialize ⇒ Names
constructor
A new instance of Names.
- #inspect ⇒ Object
- #reverse_for(name) ⇒ Object
Constructor Details
#initialize ⇒ Names
Returns a new instance of Names.
4 5 6 |
# File 'lib/rsettings/core/names.rb', line 4 def initialize @opts = {} end |
Instance Method Details
#add(opts = {}) ⇒ Object
8 9 10 11 |
# File 'lib/rsettings/core/names.rb', line 8 def add(opts={}) notify :adding, opts @opts.merge!(opts.invert) end |
#for(setting) ⇒ Object
13 14 15 16 |
# File 'lib/rsettings/core/names.rb', line 13 def for(setting) notify :finding, setting @opts[setting.to_s] || @opts[setting.to_sym] || setting end |
#inspect ⇒ Object
22 23 24 25 26 |
# File 'lib/rsettings/core/names.rb', line 22 def inspect @opts.map do |k,v| "setting <#{k}> is translated from <#{v}>" end.join "\n" end |
#reverse_for(name) ⇒ Object
18 19 20 |
# File 'lib/rsettings/core/names.rb', line 18 def reverse_for(name) @opts.invert[name.value] || name.value end |