Top Level Namespace
Defined Under Namespace
Classes: CustomBoolean
Instance Method Summary collapse
-
#if_(condition) { ... } ⇒ CustomBoolean
(also: #if!, #_if, #if?)
Equivalent of if for CustomBoolean truthiness.
-
#negate(expr) ⇒ Boolean
Equivalent of ! for CustomBoolean truthiness.
Instance Method Details
#if_(condition) { ... } ⇒ CustomBoolean Also known as: if!, _if, if?
Equivalent of if for CustomBoolean truthiness. Differs from regular if as it uses CustomBoolean truthiness
78 79 80 81 82 |
# File 'lib/custom_boolean.rb', line 78 def if_(condition, &block) truth = !!CustomBoolean.truthy?(condition) bvalue = block.call if truth CustomBoolean.new(truth, bvalue) end |
#negate(expr) ⇒ Boolean
Equivalent of ! for CustomBoolean truthiness. Differs from regular ! as it uses CustomBoolean truthiness
57 58 59 |
# File 'lib/custom_boolean.rb', line 57 def negate(expr) !CustomBoolean.truthy?(expr) end |