Class: ThomasUtils::KeyChild

Inherits:
Object
  • Object
show all
Includes:
SymbolHelpers
Defined in:
lib/thomas_utils/key_child.rb

Constant Summary

Constants included from SymbolHelpers

SymbolHelpers::OPERATOR_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SymbolHelpers

#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

#childObject (readonly)

Returns the value of attribute child.



5
6
7
# File 'lib/thomas_utils/key_child.rb', line 5

def child
  @child
end

#keyObject (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_sObject



25
26
27
# File 'lib/thomas_utils/key_child.rb', line 25

def to_s
  "#{@key}.#{@child}"
end