Class: Common::Descending
- Inherits:
-
Object
- Object
- Common::Descending
- Includes:
- Comparable
- Defined in:
- lib/common/models/comparable/descending.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
This will always force nil values to the end.
-
#initialize(obj) ⇒ Descending
constructor
A new instance of Descending.
Constructor Details
#initialize(obj) ⇒ Descending
Returns a new instance of Descending.
10 11 12 |
# File 'lib/common/models/comparable/descending.rb', line 10 def initialize(obj) @obj = obj end |
Instance Attribute Details
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
8 9 10 |
# File 'lib/common/models/comparable/descending.rb', line 8 def obj @obj end |
Instance Method Details
#<=>(other) ⇒ Object
This will always force nil values to the end
15 16 17 18 19 20 21 |
# File 'lib/common/models/comparable/descending.rb', line 15 def <=>(other) return 0 if !obj && !other.obj return 1 unless obj return -1 unless other.obj -(obj <=> other.obj) end |