Class: Semvruler::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/semvruler/order.rb

Instance Method Summary collapse

Constructor Details

#initialize(*chain) ⇒ Order

Returns a new instance of Order.



5
6
7
# File 'lib/semvruler/order.rb', line 5

def initialize(*chain)
  @chain = chain
end

Instance Method Details

#<=>(other) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/semvruler/order.rb', line 9

def <=>(other)
  index = (0..2).find { |idx| compare_at(other, idx) != 0 }
  return compare_at(other, index) if index
  return compare_missed_lenght(other) if compare_missed_lenght(other) != 0

  index = (3..[size, other.size].max).find { |idx| compare_at(other, idx) != 0 }
  return compare_at(other, index) if index

  no_difference_found
end