Class: ConfOptions::Standard

Inherits:
Hash
  • Object
show all
Defined in:
lib/confoptions.rb

Direct Known Subclasses

Array, Bool, String

Instance Method Summary collapse

Constructor Details

#initialize(init_hash) ⇒ Standard

Returns a new instance of Standard


3
4
5
# File 'lib/confoptions.rb', line 3

def initialize init_hash
    merge! init_hash
end

Instance Method Details

#getObject


9
10
11
12
13
14
15
# File 'lib/confoptions.rb', line 9

def get
    if self[:getter].is_a? Proc
        self[:getter].call self
    else
        default_getter
    end
end

#to_pairObject


6
7
8
# File 'lib/confoptions.rb', line 6

def to_pair
    [self[:name],self[:value]]
end

#to_sObject


16
17
18
19
20
# File 'lib/confoptions.rb', line 16

def to_s
    get.collect { |k,v|
        k.to_s.capitalize.gsub('_',' ') + ': ' + v.to_s
    }.join "\n"
end