Class: Antlr4::Runtime::Triple

Inherits:
Object
  • Object
show all
Defined in:
lib/antlr4/runtime/triple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a, b, c) ⇒ Triple

Returns a new instance of Triple.



7
8
9
10
11
# File 'lib/antlr4/runtime/triple.rb', line 7

def initialize(a, b, c)
  @a = a
  @b = b
  @c = c
end

Instance Attribute Details

#aObject

Returns the value of attribute a.



3
4
5
# File 'lib/antlr4/runtime/triple.rb', line 3

def a
  @a
end

#bObject

Returns the value of attribute b.



4
5
6
# File 'lib/antlr4/runtime/triple.rb', line 4

def b
  @b
end

#cObject

Returns the value of attribute c.



5
6
7
# File 'lib/antlr4/runtime/triple.rb', line 5

def c
  @c
end

Instance Method Details

#eql?(obj) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'lib/antlr4/runtime/triple.rb', line 13

def eql?(obj)
  if obj == self
    return true
  else
    return false unless obj.is_a? Triple
  end

  ObjectEqualityComparator.instance.compare(a, obj.a).zero? && ObjectEqualityComparator.instance.compare(b, obj.b).zero? && ObjectEqualityComparator.instance.compare(c, obj.c).zero?
end

#hashObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/antlr4/runtime/triple.rb', line 23

def hash
  hash_code = RumourHash.hash([@a, @b, @c])

  unless @_hash.nil?
    if hash_code == @_hash
      puts 'Same hash_code for Triple'
    else
      puts 'Different hash_code for Triple'
    end
  end
  @_hash = hash_code
end

#to_sObject



36
37
38
# File 'lib/antlr4/runtime/triple.rb', line 36

def to_s
  '(' << @a.to_s << ',' << @b.to_s << ', ' << @c.to_s << ')'
end