Sha256: 023ee1cdcddd580f3cbc2fcc8e3f8d0768200e585871cb4dc4b97fb9e9634cb8
Contents?: true
Size: 435 Bytes
Versions: 52
Compression:
Stored size: 435 Bytes
Contents
class String def to_bool return true if self == true || self =~ (/^(true|t|yes|y|1)$/i) return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i) raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") end end class TrueClass def to_i; 1; end def to_bool; self; end end class FalseClass def to_i; 0; end def to_bool; self; end end class NilClass def to_bool; false; end end
Version data entries
52 entries across 52 versions & 1 rubygems