Class: TTY::Coercer::Boolean
- Inherits:
-
Object
- Object
- TTY::Coercer::Boolean
- Defined in:
- lib/tty/coercer/boolean.rb
Overview
A class responsible for boolean type coercion
Class Method Summary collapse
-
.coerce(value) ⇒ Object
Coerce value to boolean type including range of strings such as.
Class Method Details
.coerce(value) ⇒ Object
Coerce value to boolean type including range of strings such as
other values coerced to false are:
0, f, F, FALSE, false, False, n, N, No, no, No
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tty/coercer/boolean.rb', line 24 def self.coerce(value) case value.to_s when /^(yes|y|t(rue)?|1)$/i return true when /^(no|n|f(alse)?|0)$/i return false else fail TypeError, "Expected boolean type, got #{value}" end end |