Sha256: 1f7833fcae7ded6193cf22a67b6601e3cd05679a1ac383753f6807e9bc4c209e

Contents?: true

Size: 365 Bytes

Versions: 5

Compression:

Stored size: 365 Bytes

Contents

class Object
  def to_b
    case self
    when true, false: self
    when nil: false
    else
      to_i != 0
    end
  end
end

class String
  TRUE_REGEXP = /^(yes|true|on|t|1|\-1)$/i.freeze
  FALSE_REGEXP = /^(no|false|off|f|0)$/i.freeze

  def to_b
    case self
    when TRUE_REGEXP: true
    when FALSE_REGEXP: false
    else
      to_i != 0
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ar_loader-1.0.0.0 lib/to_b.rb
ar_loader-9.9.9 lib/to_b.rb
ar_loader-0.0.9 lib/to_b.rb
ar_loader-0.0.8 lib/to_b.rb
ar_loader-0.0.4 lib/to_b.rb