lib/oedipus/comparison.rb
# Return a suitable comparison object for +v+.
#
# The conversions are:
#
#   - leave Comparison objects unchanged
#   - convert real ranges to Between comparisons
#   - convert Infinity-bounded exclusive ranges to GT/LT comparisons
#   - convert Infinity-bounded inclusive ranges to GTE/LTE comparisons.
#   - convert everything else to an Equal comparison
#
# @param [Object] v
#   a ruby object to be compared
#
# @param [Comparison]
#   a comparison suitable for comparing the input
Return a suitable comparison object for +v+.
The conversions are.

leave Comparison objects unchanged
convert real ranges to Between comparisons
convert Infinity-bounded exclusive ranges to GT/LT comparisons
convert Infinity-bounded inclusive ranges to GTE/LTE comparisons.
convert everything else to an Equal comparison
Return a suitable comparison object for + v + . The conversions are . leave Comparison objects unchanged convert real ranges to Between comparisons convert Infinity - bounded exclusive ranges to GT / LT comparisons convert Infinity - bounded inclusive ranges to GTE / LTE comparisons . convert everything else to an Equal comparison
def of(v)
        case v
        when Comparison
          v
        when Range
          if v.end == Float::INFINITY
            v.exclude_end? ? Shortcuts.gt(v.first) : Shortcuts.gte(v.first)
          elsif v.first == -Float::INFINITY
            v.exclude_end? ? Shortcuts.lt(v.end) : Shortcuts.lte(v.end)
          else
            Shortcuts.between(v)
          end
        when Enumerable
          Shortcuts.in(v)
        else
          Shortcuts.eq(v)
        end
      end
def of ( v ) case v when Comparison v when Range if v . end == Float :: INFINITY v . exclude_end? ? Shortcuts . gt ( v . first ) : Shortcuts . gte ( v . first ) elsif v . first == - Float :: INFINITY v . exclude_end? ? Shortcuts . lt ( v . end ) : Shortcuts . lte ( v . end ) else Shortcuts . between ( v ) end when Enumerable Shortcuts . in ( v ) else Shortcuts . eq ( v ) end end
Return a suitable comparison object for +v+.
Return a suitable comparison object for + v + .
v
<not_specific>
<not_specific>
a comparison suitable for comparing the input
a comparison suitable for comparing the input