Method: ATypes::BooleanWrap#to_bool
- Defined in:
- lib/a_types/decorators/boolean_wrap.rb
#to_bool ⇒ true, ... Also known as: truth, to_b
Extracts the truth from this BooleanWrap’s value according to the following rules:
-
for any kind of numeric: values above 0 are true, others false.
-
for strings: any string equal to either of the following
["y", "Y", "1", "yes", "Yes", "YES", "true", "True", "TRUE"]will be true, any string equal to either of these
["n", "N", "-1", "no", "No", "NO", "false", "False", "FALSE"]will be false.
-
any other object will be transformed to a hard boolean according Ruby’s default truthy evaluation.
26 27 28 |
# File 'lib/a_types/decorators/boolean_wrap.rb', line 26 def to_bool @truth ||= extract_truth(content) end |