Class: ThomasUtils::KeyChild
- Inherits:
-
Object
- Object
- ThomasUtils::KeyChild
- Includes:
- SymbolHelpers
- Defined in:
- lib/thomas_utils/key_child.rb
Constant Summary
Constants included from SymbolHelpers
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, child) ⇒ KeyChild
constructor
A new instance of KeyChild.
- #new_key(key) ⇒ Object
- #quote(quote) ⇒ Object
- #to_s ⇒ Object
Methods included from SymbolHelpers
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 (readonly)
Returns the value of attribute child.
5 6 7 |
# File 'lib/thomas_utils/key_child.rb', line 5 def child @child end |
#key ⇒ Object (readonly)
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
#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 |