Easily cast any type to boolean in Ruby

module StringToBoolean
  def to_bool
    return true if self == true || self.strip =~ (/\A(true|t|yes|y|1)\Z/i)
    false
  end
end
class String; include StringToBoolean; end

module BooleanToBoolean
  def to_bool;return self; end
end

class TrueClass; include BooleanToBoolean; end
class FalseClass; include BooleanToBoolean; end

module NilToBoolean
  def to_bool
    false
  end
end
class NilClass; include NilToBoolean; end

module NumberoBoolean
  def to_bool
    return false if self == 0
    true
  end
end
class Integer; include NumberoBoolean; end
class Fixnum; include NumberoBoolean; end
class Bignum; include NumberoBoolean; end
class Float; include NumberoBoolean; end
class Rational; include NumberoBoolean; end