Class: Fuelcell::Action::OptResults
- Inherits:
-
Hash
- Object
- Hash
- Fuelcell::Action::OptResults
show all
- Defined in:
- lib/fuelcell/action/opt_results.rb
Instance Method Summary
collapse
Constructor Details
#initialize(hash = {}) ⇒ OptResults
Returns a new instance of OptResults.
5
6
7
8
9
10
|
# File 'lib/fuelcell/action/opt_results.rb', line 5
def initialize(hash = {})
super()
hash.each do |key, value|
self[normalize(key)] = value
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &_block) ⇒ Object
61
62
63
64
65
|
# File 'lib/fuelcell/action/opt_results.rb', line 61
def method_missing(method_name, *args, &_block)
name = method_name.to_s
return self.key?(name.chomp('?')) if name[-1] == '?'
return self[name]
end
|
Instance Method Details
#[](key) ⇒ Object
12
13
14
|
# File 'lib/fuelcell/action/opt_results.rb', line 12
def [](key)
super(normalize(key))
end
|
#[]=(key, value) ⇒ Object
16
17
18
|
# File 'lib/fuelcell/action/opt_results.rb', line 16
def []=(key, value)
super(normalize(key), value)
end
|
#delete(key) ⇒ Object
20
21
22
|
# File 'lib/fuelcell/action/opt_results.rb', line 20
def delete(key)
super(normalize(key))
end
|
#fetch(key, *args) ⇒ Object
24
25
26
|
# File 'lib/fuelcell/action/opt_results.rb', line 24
def fetch(key, *args)
super(normalize(key), *args)
end
|
#key?(key) ⇒ Boolean
28
29
30
|
# File 'lib/fuelcell/action/opt_results.rb', line 28
def key?(key)
super(normalize(key))
end
|
#merge(hash) ⇒ Object
36
37
38
|
# File 'lib/fuelcell/action/opt_results.rb', line 36
def merge(hash)
dup.merge!(hash)
end
|
#merge!(hash) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/fuelcell/action/opt_results.rb', line 40
def merge!(hash)
hash.each do |key, value|
self[normalize(key)] = value
end
self
end
|
#respond_to?(method_name, include_private = false) ⇒ Boolean
51
52
53
|
# File 'lib/fuelcell/action/opt_results.rb', line 51
def respond_to?(method_name, include_private = false)
return key?(method_name.to_s.chomp('?')) || super
end
|
#to_hash ⇒ Object
47
48
49
|
# File 'lib/fuelcell/action/opt_results.rb', line 47
def to_hash
Hash.new(default).merge!(self)
end
|
#values_at(*indices) ⇒ Object
32
33
34
|
# File 'lib/fuelcell/action/opt_results.rb', line 32
def values_at(*indices)
indices.map { |key| self[normalize(key)] }
end
|