Module: CMDx::Coercions::Boolean
Overview
Constant Summary collapse
- TRUTHY =
Set["true", "yes", "on", "y", "1", "t"].freeze
- FALSEY =
Set["false", "no", "off", "n", "0", "f"].freeze
Instance Method Summary collapse
Instance Method Details
#call(value, options = EMPTY_HASH) ⇒ Boolean, Coercions::Failure
19 20 21 22 23 24 25 26 27 |
# File 'lib/cmdx/coercions/boolean.rb', line 19 def call(value, = EMPTY_HASH) return coercion_failure if value.nil? str = value.to_s.strip.downcase return true if TRUTHY.include?(str) return false if FALSEY.include?(str) coercion_failure end |