Class: Put::PutsThing

Inherits:
Object
  • Object
show all
Defined in:
lib/put/puts_thing.rb,
lib/put/puts_thing/last.rb,
lib/put/puts_thing/first.rb,
lib/put/puts_thing/anywhere.rb,
lib/put/puts_thing/in_order.rb,
lib/put/puts_thing/ascending.rb,
lib/put/puts_thing/nil_order.rb,
lib/put/puts_thing/nils_last.rb,
lib/put/puts_thing/descending.rb,
lib/put/puts_thing/nils_first.rb

Direct Known Subclasses

Anywhere, First, InOrder, Last, NilOrder

Defined Under Namespace

Classes: Anywhere, Ascending, Descending, First, InOrder, Last, NilOrder, NilsFirst, NilsLast

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/put/puts_thing.rb', line 3

def <=>(other)
  if value.nil? && (other.nil? || other&.value.nil?)
    0
  elsif value.nil?
    nils_first? ? -1 : 1
  elsif other.nil? || other&.value.nil?
    nils_first? ? 1 : -1
  elsif other && !other.reverse?
    value <=> other.value
  elsif other&.reverse?
    other.value <=> value
  else
    value <=> 0
  end
end

#nils_first?Boolean



23
24
25
# File 'lib/put/puts_thing.rb', line 23

def nils_first?
  false
end

#reverse?Boolean



19
20
21
# File 'lib/put/puts_thing.rb', line 19

def reverse?
  false
end