Class: Invert
- Inherits:
-
Object
- Object
- Invert
- Defined in:
- lib/invert.rb
Overview
Wrap an object to invert <=>
method.
items.sort_by {|r| [r.prop1, Invert.new(r.prop2)]}
Instance Attribute Summary collapse
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(r) ⇒ Invert
constructor
A new instance of Invert.
Constructor Details
#initialize(r) ⇒ Invert
Returns a new instance of Invert.
19 20 21 |
# File 'lib/invert.rb', line 19 def initialize(r) @r = r end |
Instance Attribute Details
#r ⇒ Object (readonly)
Returns the value of attribute r.
17 18 19 |
# File 'lib/invert.rb', line 17 def r @r end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 |
# File 'lib/invert.rb', line 23 def <=>(other) -(@r <=> other.r) end |