Method: Lotus::Utils::Kernel.Boolean
- Defined in:
- lib/lotus/utils/kernel.rb
.Boolean(arg) ⇒ true, false
Coerces the argument to be a Boolean.
911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/lotus/utils/kernel.rb', line 911 def self.Boolean(arg) case arg when Numeric then arg > 0 && arg <= 1 when String, '0' then Boolean(arg.to_i) when ->(a) { a.respond_to?(:to_bool) } then arg.to_bool else !!arg end rescue NoMethodError raise TypeError.new "can't convert #{inspect_type_error(arg)}into Boolean" end |