class Necromancer::BooleanConverters::StringToBooleanConverter

An object that converts a String to a Boolean

Public Instance Methods

call(value, strict: config.strict) click to toggle source

Convert value to boolean type including range of strings

@param [Object] value

@example

converter.call("True") # => true

other values converted to true are:
  1, t, T, TRUE,  true,  True,  y, Y, YES, yes, Yes, on, ON

@example

 converter.call("False") # => false

other values coerced to false are:
  0, f, F, FALSE, false, False, n, N, NO,  no,  No, off, OFF

@api public

# File lib/necromancer/converters/boolean.rb, line 32
def call(value, strict: config.strict)
  case value.to_s
  when TRUE_MATCHER then true
  when FALSE_MATCHER then false
  else strict ? raise_conversion_type(value) : value
  end
end