module Comparable

workaround for an infinite loop in Opal 0.6.2 when comparing numbers

Public Instance Methods

<(other) click to toggle source
# File lib/asciidoctor/opal_ext/comparable.rb, line 25
def < other
  unless cmp = (self <=> other)
    raise ArgumentError, "comparison of #{self.class} with #{other.class} failed"
  end
  %xcmp < 0`
end
<=(other) click to toggle source
# File lib/asciidoctor/opal_ext/comparable.rb, line 32
def <= other
  unless cmp = (self <=> other)
    raise ArgumentError, "comparison of #{self.class} with #{other.class} failed"
  end
  %xcmp <= 0`
end
==(other) click to toggle source
# File lib/asciidoctor/opal_ext/comparable.rb, line 3
def == other
  return true if equal? other
  return false unless cmp = (self <=> other)
  return %xcmp == 0`
rescue StandardError
  false
end
>(other) click to toggle source
# File lib/asciidoctor/opal_ext/comparable.rb, line 11
def > other
  unless cmp = (self <=> other)
    raise ArgumentError, "comparison of #{self.class} with #{other.class} failed"
  end
  %xcmp > 0`
end
>=(other) click to toggle source
# File lib/asciidoctor/opal_ext/comparable.rb, line 18
def >= other 
  unless cmp = (self <=> other)
    raise ArgumentError, "comparison of #{self.class} with #{other.class} failed"
  end
  %xcmp >= 0`
end