Class: Tabry::CLI::FlagProxy
- Inherits:
-
Object
- Object
- Tabry::CLI::FlagProxy
show all
- Defined in:
- lib/tabry/cli/flag_proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ FlagProxy
Returns a new instance of FlagProxy.
6
7
8
|
# File 'lib/tabry/cli/flag_proxy.rb', line 6
def initialize(hash)
@hash = hash
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(met, default = nil, *_args) ⇒ Object
32
33
34
|
# File 'lib/tabry/cli/flag_proxy.rb', line 32
def method_missing(met, default = nil, *_args)
self[met] || default
end
|
Instance Method Details
#[](key) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/tabry/cli/flag_proxy.rb', line 10
def [](key)
key = key.to_s
[
key,
key.gsub("_", "-")
].each do |hash_key|
val = @hash[hash_key]
return val if val
end
nil
end
|
#inspect ⇒ Object
40
41
42
|
# File 'lib/tabry/cli/flag_proxy.rb', line 40
def inspect
"FlagProxy: #{@hash.inspect}"
end
|
#respond_to_missing?(*_args) ⇒ Boolean
36
37
38
|
# File 'lib/tabry/cli/flag_proxy.rb', line 36
def respond_to_missing?(*_args)
true
end
|
#slice(*keys) ⇒ Object
26
27
28
29
30
|
# File 'lib/tabry/cli/flag_proxy.rb', line 26
def slice(*keys)
[keys].flatten.each_with_object({}) do |key, result_hash|
result_hash[key] = self[key]
end
end
|
#to_hash ⇒ Object
22
23
24
|
# File 'lib/tabry/cli/flag_proxy.rb', line 22
def to_hash
@hash
end
|
#to_s ⇒ Object
44
45
46
|
# File 'lib/tabry/cli/flag_proxy.rb', line 44
def to_s
"FlagProxy: #{@hash}"
end
|