Sha256: 7975f8fb99ad256db926f63b3f8d3f88a169dffc734d4e25440acb25445ae04e

Contents?: true

Size: 342 Bytes

Versions: 9

Compression:

Stored size: 342 Bytes

Contents

# frozen_string_literal: true

class Integer
  def to_bool
    return true if self == 1
    return false if zero?
    raise "Fixnum '#{self}' can't be converted to Boolean."
  end
end

class String
  def to_bool
    return true if to_i == 1
    return false if to_i.zero?
    raise "String '#{self}' can't be converted to Boolean."
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta15 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta14 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta13 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta12 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta11 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta10 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta9 lib/ext/to_bool.rb
ffi-gdal-1.0.0.beta8 lib/ext/to_bool.rb