Class: Playbook::Tokens::ColorHash
- Inherits:
-
Object
- Object
- Playbook::Tokens::ColorHash
show all
- Defined in:
- lib/playbook/tokens.rb
Overview
Hash wrapper supporting colors and colors.key
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ ColorHash
Returns a new instance of ColorHash.
58
59
60
|
# File 'lib/playbook/tokens.rb', line 58
def initialize(hash)
@hash = hash.freeze
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/playbook/tokens.rb', line 66
def method_missing(method_name, *args, &block)
key = method_name.to_sym
if @hash.key?(key)
@hash[key]
else
super
end
end
|
Instance Method Details
#[](key) ⇒ Object
62
63
64
|
# File 'lib/playbook/tokens.rb', line 62
def [](key)
@hash[key.to_sym]
end
|
#key?(key) ⇒ Boolean
Also known as:
has_key?
93
94
95
|
# File 'lib/playbook/tokens.rb', line 93
def key?(key)
@hash.key?(key.to_sym)
end
|
#keys ⇒ Object
85
86
87
|
# File 'lib/playbook/tokens.rb', line 85
def keys
@hash.keys
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
75
76
77
|
# File 'lib/playbook/tokens.rb', line 75
def respond_to_missing?(method_name, include_private = false)
@hash.key?(method_name.to_sym) || super
end
|
#to_h ⇒ Object
Also known as:
to_hash
79
80
81
|
# File 'lib/playbook/tokens.rb', line 79
def to_h
@hash
end
|
#values ⇒ Object
89
90
91
|
# File 'lib/playbook/tokens.rb', line 89
def values
@hash.values
end
|