Class: ThomasUtils::KeyChild
- Inherits:
-
Object
- Object
- ThomasUtils::KeyChild
show all
- Includes:
- SymbolHelpers
- Defined in:
- lib/thomas_utils/key_child.rb
Constant Summary
SymbolHelpers::OPERATOR_MAP
Instance Attribute Summary collapse
Instance Method Summary
collapse
#index
Constructor Details
#initialize(key, child) ⇒ KeyChild
Returns a new instance of KeyChild.
7
8
9
10
|
# File 'lib/thomas_utils/key_child.rb', line 7
def initialize(key, child)
@key = key
@child = child
end
|
Instance Attribute Details
#child ⇒ Object
Returns the value of attribute child.
5
6
7
|
# File 'lib/thomas_utils/key_child.rb', line 5
def child
@child
end
|
#key ⇒ Object
Returns the value of attribute key.
5
6
7
|
# File 'lib/thomas_utils/key_child.rb', line 5
def key
@key
end
|
Instance Method Details
#==(rhs) ⇒ Object
Also known as:
eql?
29
30
31
|
# File 'lib/thomas_utils/key_child.rb', line 29
def ==(rhs)
rhs.is_a?(KeyChild) && key == rhs.key && child == rhs.child
end
|
#hash ⇒ Object
34
35
36
|
# File 'lib/thomas_utils/key_child.rb', line 34
def hash
to_s.hash
end
|
#new_key(key) ⇒ Object
12
13
14
|
# File 'lib/thomas_utils/key_child.rb', line 12
def new_key(key)
KeyChild.new(key, child)
end
|
#quote(quote) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/thomas_utils/key_child.rb', line 16
def quote(quote)
quoted_key = if key.respond_to?(:quote)
key.quote(quote)
else
"#{quote}#{key}#{quote}"
end
"#{quoted_key}.#{quote}#{child}#{quote}"
end
|
#to_s ⇒ Object
25
26
27
|
# File 'lib/thomas_utils/key_child.rb', line 25
def to_s
"#{@key}.#{@child}"
end
|