Class: Common::Ascending
- Inherits:
-
Object
- Object
- Common::Ascending
- Includes:
- Comparable
- Defined in:
- lib/common/models/comparable/ascending.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) ⇒ Ascending
constructor
A new instance of Ascending.
Constructor Details
#initialize(obj) ⇒ Ascending
Returns a new instance of Ascending.
10 11 12 |
# File 'lib/common/models/comparable/ascending.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/ascending.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/ascending.rb', line 15 def <=>(other) return 0 if !obj && !other.obj return 1 unless obj return -1 unless other.obj obj <=> other.obj end |