Module: Oedipus::Comparison::Shortcuts
- Extended by:
- Shortcuts
- Defined in:
- lib/oedipus/comparison/shortcuts.rb
Overview
Provides short methods for casting values to Comparisons.
Instance Method Summary collapse
-
#between(a, b = nil) ⇒ Comparison::Between
Return the Comparison for the range a..b.
-
#eq(v) ⇒ Comparison::Equal
Return the Comparison for equality of
v
. -
#gt(v) ⇒ Comparison::GT
Return the Comparison for >
v
. -
#gte(v) ⇒ Comparison::GTE
Return the Comparison for >=
v
. -
#in(*v) ⇒ Comparison::In
Return the Comparison for any value in the set
v
. -
#lt(v) ⇒ Comparison::LT
Return the Comparison for <
v
. -
#lte(v) ⇒ Comparison::LTE
Return the Comparison for <=
v
. -
#neq(v) ⇒ Comparison::Equal
Return the Comparison for inequality of
v
. -
#not(v) ⇒ Comparison::Not
Return the Comparison for negation of
v
. -
#not_in(*v) ⇒ Comparison::NotIn
Return the Comparison for any value NOT in the set
v
. -
#outside(a, b = nil) ⇒ Comparison::Outside
Return the Comparison to exclude the range a..b.
Instance Method Details
#between(a, b = nil) ⇒ Comparison::Between
Return the Comparison for the range a..b.
59 60 61 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 59 def between(a, b = nil) Between.new(a.kind_of?(Range) ? a : a..b) end |
#eq(v) ⇒ Comparison::Equal
Return the Comparison for equality of v
.
23 24 25 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 23 def eq(v) Equal.new(v) end |
#gt(v) ⇒ Comparison::GT
Return the Comparison for > v
.
117 118 119 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 117 def gt(v) GT.new(v) end |
#gte(v) ⇒ Comparison::GTE
Return the Comparison for >= v
.
106 107 108 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 106 def gte(v) GTE.new(v) end |
#in(*v) ⇒ Comparison::In
Return the Comparison for any value in the set v
.
84 85 86 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 84 def in(*v) In.new(v.map { |el| el.respond_to?(:to_a) ? el.to_a : el }.flatten) end |
#lt(v) ⇒ Comparison::LT
Return the Comparison for < v
.
139 140 141 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 139 def lt(v) LT.new(v) end |
#lte(v) ⇒ Comparison::LTE
Return the Comparison for <= v
.
128 129 130 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 128 def lte(v) LTE.new(v) end |
#neq(v) ⇒ Comparison::Equal
Return the Comparison for inequality of v
.
34 35 36 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 34 def neq(v) NotEqual.new(v) end |
#not(v) ⇒ Comparison::Not
Return the Comparison for negation of v
.
45 46 47 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 45 def not(v) Not.new(v) end |
#not_in(*v) ⇒ Comparison::NotIn
Return the Comparison for any value NOT in the set v
.
95 96 97 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 95 def not_in(*v) NotIn.new(v.map { |el| el.respond_to?(:to_a) ? el.to_a : el }.flatten) end |
#outside(a, b = nil) ⇒ Comparison::Outside
Return the Comparison to exclude the range a..b.
73 74 75 |
# File 'lib/oedipus/comparison/shortcuts.rb', line 73 def outside(a, b = nil) Outside.new(a.kind_of?(Range) ? a : a..b) end |