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-2.3.4 lib/evertils/kernel.rb
evertils-2.3.3 lib/evertils/kernel.rb
evertils-2.3.2 lib/evertils/kernel.rb
evertils-2.3.1 lib/evertils/kernel.rb
evertils-2.3.0 lib/evertils/kernel.rb
evertils-2.2.4 lib/evertils/kernel.rb
evertils-2.2.3 lib/evertils/kernel.rb
evertils-2.2.2 lib/evertils/kernel.rb
evertils-2.2.1 lib/evertils/kernel.rb
evertils-2.2.0 lib/evertils/kernel.rb
evertils-2.1.0 lib/evertils/kernel.rb
evertils-2.0.2 lib/evertils/kernel.rb
evertils-2.0.1 lib/evertils/kernel.rb
evertils-2.0.0 lib/evertils/kernel.rb
evertils-1.0.12 lib/evertils/kernel.rb
evertils-1.0.11 lib/evertils/kernel.rb
evertils-1.0.10 lib/evertils/kernel.rb
evertils-1.0.9 lib/evertils/kernel.rb
evertils-1.0.8 lib/evertils/kernel.rb
evertils-1.0.7 lib/evertils/kernel.rb