Sha256: 7aedee8e135e5c8f65e319e8ef1765695e4e4e2b9947feb7581f6de89d2b7256

Contents?: true

Size: 870 Bytes

Versions: 5

Compression:

Stored size: 870 Bytes

Contents

module Antlr4::Runtime
  class Triple
    attr_accessor :a
    attr_accessor :b
    attr_accessor :c

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

    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

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

      if !@_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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
antlr4-runtime-0.2.8 lib/antlr4/runtime/triple.rb
antlr4-runtime-0.2.7 lib/antlr4/runtime/triple.rb
antlr4-runtime-0.2.6 lib/antlr4/runtime/triple.rb
antlr4-runtime-0.2.5 lib/antlr4/runtime/triple.rb
antlr4-runtime-0.2.4 lib/antlr4/runtime/triple.rb