Class: AMA::Entity::Mapper::Type::Aux::HashTuple

Inherits:
Object
  • Object
show all
Defined in:
lib/ama-entity-mapper/type/aux/hash_tuple.rb

Overview

Simple class to store paired data items

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: nil, value: nil) ⇒ HashTuple

Returns a new instance of HashTuple.



13
14
15
16
# File 'lib/ama-entity-mapper/type/aux/hash_tuple.rb', line 13

def initialize(key: nil, value: nil)
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



10
11
12
# File 'lib/ama-entity-mapper/type/aux/hash_tuple.rb', line 10

def key
  @key
end

#valueObject

Returns the value of attribute value.



11
12
13
# File 'lib/ama-entity-mapper/type/aux/hash_tuple.rb', line 11

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/ama-entity-mapper/type/aux/hash_tuple.rb', line 27

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/ama-entity-mapper/type/aux/hash_tuple.rb', line 22

def eql?(other)
  return false unless other.is_a?(HashTuple)
  @key == other.key && @value == other.value
end

#hashObject



18
19
20
# File 'lib/ama-entity-mapper/type/aux/hash_tuple.rb', line 18

def hash
  @key.hash ^ @value.hash
end