Module: CustomBoolean::Operators

Defined in:
lib/custom_boolean.rb

Instance Method Summary collapse

Instance Method Details

#&(other) ⇒ Boolean Also known as: and

Equivalent of *&&* for CustomBoolean truthiness. Differs from regular *&&* as it uses CustomBoolean truthiness

NOTE: It is usually better to use the #and alias, as fewer objects override this method)

Examples:

obj1 & obj2
obj1.and obj2

Parameters:

  • other

    The rhs of the boolean and operator

Returns:

  • (Boolean)


22
23
24
# File 'lib/custom_boolean.rb', line 22

def &(other)
  CustomBoolean.truthy?(self) && CustomBoolean.truthy?(other)
end

#|(other) ⇒ Boolean Also known as: or

Equivalent of *||* for CustomBoolean truthiness. Differs from regular *||* as it uses CustomBoolean truthiness

NOTE: It is usually better to use the #or alias, as fewer objects override this method)

Examples:

obj1 | obj2
obj1.or obj2

Parameters:

  • other

    The rhs of the boolean or operator

Returns:

  • (Boolean)


38
39
40
# File 'lib/custom_boolean.rb', line 38

def |(other)
  CustomBoolean.truthy?(self) || CustomBoolean.truthy?(other)
end