Sha256: 88d16459ab5611df16fe27e0aac50219e9859419a0d6f1529760f2f7b0bde67d

Contents?: true

Size: 601 Bytes

Versions: 40

Compression:

Stored size: 601 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 Fixnum
  def to_bool
    return true if self == 1
    return false if self == 0
    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

40 entries across 40 versions & 2 rubygems

Version Path
bonethug-0.0.99 lib/init.rb
bonethug-0.0.98 lib/init.rb
evertils-0.1.20 lib/kernel.rb
evertils-0.1.19 lib/kernel.rb
evertils-0.1.18 lib/kernel.rb
evertils-0.1.17 lib/kernel.rb
evertils-0.1.15 lib/kernel.rb
evertils-0.1.14 lib/kernel.rb
evertils-0.1.13 lib/kernel.rb
evertils-0.1.12 lib/kernel.rb
evertils-0.1.11 lib/kernel.rb
bonethug-0.0.97 lib/init.rb
evertils-0.1.9 lib/kernel.rb
evertils-0.1.8 lib/kernel.rb
evertils-0.1.7 lib/kernel.rb
evertils-0.1.6 lib/kernel.rb
evertils-0.1.5 lib/kernel.rb
evertils-0.1.4 lib/kernel.rb
evertils-0.1.3 lib/kernel.rb
evertils-0.1.2 lib/kernel.rb