Class: ConfOptions::Standard
- Inherits:
-
Hash
- Object
- Hash
- ConfOptions::Standard
- Defined in:
- lib/confoptions.rb
Overview
Most common option. Only custom validator and getter supports
Instance Method Summary collapse
-
#get ⇒ Object
parse otion into some (hash most likely) by using getter Proc.
-
#initialize(init_hash) ⇒ Standard
constructor
A new instance of Standard.
-
#to_pair ⇒ Object
return [name, value] pair.
-
#to_s ⇒ Object
human readable representation.
Constructor Details
#initialize(init_hash) ⇒ Standard
Returns a new instance of Standard.
4 5 6 |
# File 'lib/confoptions.rb', line 4 def initialize init_hash merge! init_hash end |
Instance Method Details
#get ⇒ Object
parse otion into some (hash most likely) by using getter Proc
12 13 14 15 16 17 18 19 20 |
# File 'lib/confoptions.rb', line 12 def get if self[:getter].is_a? Proc self[:getter].call self elsif (private_methods + methods).include? :default_getter default_getter else fallback_getter end end |
#to_pair ⇒ Object
return [name, value] pair
8 9 10 |
# File 'lib/confoptions.rb', line 8 def to_pair [self[:name],self[:value]] end |
#to_s ⇒ Object
human readable representation
22 23 24 25 26 |
# File 'lib/confoptions.rb', line 22 def to_s get.collect { |k,v| k.to_s.capitalize.gsub('_',' ') + ': ' + v.to_s }.join "\n" end |