Class: Clomp::Option
- Inherits:
-
Hash
- Object
- Hash
- Clomp::Option
show all
- Defined in:
- lib/clomp/option.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/clomp/option.rb', line 18
def method_missing(name, *args)
name_string = name.to_s
if name_string.chomp!('=')
self[name_string] = args.first
else
bangs = name_string.chomp!('!')
if bangs
fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is blank."))
else
self[name_string]
end
end
end
|
Instance Method Details
#[](key) ⇒ Object
10
11
12
|
# File 'lib/clomp/option.rb', line 10
def [](key)
super(key.to_sym)
end
|
#[]=(key, value) ⇒ Object
6
7
8
|
# File 'lib/clomp/option.rb', line 6
def []=(key, value)
super(key.to_sym, value)
end
|
#respond_to_missing?(name, include_private) ⇒ Boolean
33
34
35
|
# File 'lib/clomp/option.rb', line 33
def respond_to_missing?(name, include_private)
true
end
|
#set(key, value) ⇒ Object
14
15
16
|
# File 'lib/clomp/option.rb', line 14
def set(key, value)
self[key] = value
end
|