Module: OpenAPISourceTools::Ordering

Defined in:
lib/openapi/sourcetools/order.rb

Overview

Ordering methods and classes for openapi-order.

Defined Under Namespace

Classes: KeyPath, KeyPathOrder, KeyPattern, Order

Constant Summary collapse

ANY =

Used as replacement for '*'.

Regexp.new('^.*$')

Class Method Summary collapse

Class Method Details

.array_item_compare(a, b) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/openapi/sourcetools/order.rb', line 13

def self.array_item_compare(a, b)
  a[:values].size.times do |k|
    av = a[:values][k]
    bv = b[:values][k]
    if av.nil?
      return 1 unless bv.nil?
    else
      return -1 if bv.nil?
      r = av <=> bv
      return r unless r.nil? || r.zero?
    end
  end
  0
end