Module: TrickBag::Operators
- Defined in:
- lib/trick_bag/operators/operators.rb
Class Method Summary collapse
-
.multi_eq(*values) ⇒ Object
Returns whether or not all passed values are equal.
Class Method Details
.multi_eq(*values) ⇒ Object
Returns whether or not all passed values are equal
Ex: multi_eq(1, 1, 1, 2) => false; multi_eq(1, 1, 1, 1) => true
9 10 11 12 13 14 |
# File 'lib/trick_bag/operators/operators.rb', line 9 def multi_eq(*values) # If there is only 1 arg, it must be an array of at least 2 elements. values = values.first if values.first.is_a?(Array) && values.size == 1 raise ArgumentError.new("Must be called with at least 2 parameters; was: #{values.inspect}") if values.size < 2 values[1..-1].all? { |value| value == values.first } end |