Class: ActiveRecord::Lint::Pair
- Inherits:
-
Object
- Object
- ActiveRecord::Lint::Pair
- Includes:
- Comparable
- Defined in:
- lib/active_record/lint/pairs.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(a, b) ⇒ Pair
constructor
A new instance of Pair.
- #inspect ⇒ Object
- #pair_name ⇒ Object
- #to_ary ⇒ Object (also: #to_a)
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
#a ⇒ Object
Returns the value of attribute a.
4 5 6 |
# File 'lib/active_record/lint/pairs.rb', line 4 def a @a end |
#b ⇒ Object
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
14 15 16 |
# File 'lib/active_record/lint/pairs.rb', line 14 def eql?(other) (self <=> other) == 0 end |
#hash ⇒ Object
26 27 28 |
# File 'lib/active_record/lint/pairs.rb', line 26 def hash a.hash ^ b.hash end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/active_record/lint/pairs.rb', line 22 def inspect "#{pair_name}[#{a.inspect}, #{b.inspect}]" end |
#pair_name ⇒ Object
18 19 20 |
# File 'lib/active_record/lint/pairs.rb', line 18 def pair_name @pair_name ||= self.class.name.split("::").last end |
#to_ary ⇒ Object Also known as: to_a
30 31 32 |
# File 'lib/active_record/lint/pairs.rb', line 30 def to_ary [a,b] end |