module BeBoolean

Public Class Methods

get(val) click to toggle source
# File lib/be_boolean.rb, line 3
def self.get(val)
  return true if val.kind_of?(TrueClass)
  return false if val.kind_of?(FalseClass)

  if val.kind_of?(String)
    down = val.downcase
    return !!/1|true|t|yes|y/.match(down)
  end

  if val.kind_of?(Integer) || val.kind_of?(Float)
    return val != 0
  end

  false
end