Class: ActiveRecord::Lint::Pair

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/active_record/lint/pairs.rb

Direct Known Subclasses

TableColumnPair

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a, b) ⇒ Pair

Returns a new instance of Pair.



6
7
8
# File 'lib/active_record/lint/pairs.rb', line 6

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

Instance Attribute Details

#aObject

Returns the value of attribute a.



4
5
6
# File 'lib/active_record/lint/pairs.rb', line 4

def a
  @a
end

#bObject

Returns the value of attribute b.



4
5
6
# File 'lib/active_record/lint/pairs.rb', line 4

def b
  @b
end

Instance Method Details

#<=>(other) ⇒ Object



10
11
12
# File 'lib/active_record/lint/pairs.rb', line 10

def <=>(other)
  (a <=> other.a).zero? ? (b <=> other.b) : (a <=> other.a)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/active_record/lint/pairs.rb', line 14

def eql?(other)
  (self <=> other) == 0
end

#hashObject



26
27
28
# File 'lib/active_record/lint/pairs.rb', line 26

def hash
  a.hash ^ b.hash
end

#inspectObject



22
23
24
# File 'lib/active_record/lint/pairs.rb', line 22

def inspect
  "#{pair_name}[#{a.inspect}, #{b.inspect}]"
end

#pair_nameObject



18
19
20
# File 'lib/active_record/lint/pairs.rb', line 18

def pair_name
  @pair_name ||= self.class.name.split("::").last
end

#to_aryObject Also known as: to_a



30
31
32
# File 'lib/active_record/lint/pairs.rb', line 30

def to_ary
  [a,b]
end