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

Version Path
evertils-1.0.6 lib/evertils/kernel.rb
evertils-1.0.5 lib/evertils/kernel.rb
evertils-1.0.4 lib/evertils/kernel.rb
evertils-1.0.3 lib/evertils/kernel.rb
evertils-1.0.2 lib/evertils/kernel.rb
evertils-1.0.1 lib/evertils/kernel.rb
evertils-1.0.0 lib/evertils/kernel.rb
evertils-0.4.0 lib/evertils/kernel.rb
evertils-0.3.27 lib/evertils/kernel.rb
evertils-0.3.26 lib/evertils/kernel.rb
evertils-0.3.25 lib/evertils/kernel.rb
evertils-0.3.24 lib/evertils/kernel.rb
evertils-0.3.23 lib/evertils/kernel.rb
evertils-0.3.22 lib/evertils/kernel.rb
evertils-0.3.21 lib/evertils/kernel.rb
evertils-0.3.20 lib/evertils/kernel.rb
evertils-0.3.19 lib/evertils/kernel.rb
evertils-0.3.18 lib/evertils/kernel.rb
evertils-0.3.17 lib/evertils/kernel.rb
evertils-0.3.16 lib/evertils/kernel.rb