Class: ThomasUtils::KeyIndexer

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

Constant Summary

Constants included from SymbolHelpers

SymbolHelpers::OPERATOR_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SymbolHelpers

#child

Constructor Details

#initialize(key, index) ⇒ KeyIndexer

Returns a new instance of KeyIndexer.



7
8
9
10
# File 'lib/thomas_utils/key_indexer.rb', line 7

def initialize(key, index)
  @key = key
  @index = index
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

Instance Method Details

#==(rhs) ⇒ Object Also known as: eql?



16
17
18
# File 'lib/thomas_utils/key_indexer.rb', line 16

def ==(rhs)
  rhs.is_a?(KeyIndexer) && key == rhs.key && index == rhs.index
end

#hashObject



21
22
23
# File 'lib/thomas_utils/key_indexer.rb', line 21

def hash
  to_s.hash
end

#to_sObject



12
13
14
# File 'lib/thomas_utils/key_indexer.rb', line 12

def to_s
  "#{key}['#{index}']"
end