Sha256: 86cd1d504eabaa382683ef92e8195597569d39699fbd8fee63d04b06035adb37

Contents?: true

Size: 374 Bytes

Versions: 34

Compression:

Stored size: 374 Bytes

Contents

class Object
  def blank?
    respond_to?(:empty?) ? empty? : !self
  end

  def present?
    !blank?
  end
end


class String
  def to_bool
    return true  if self == true  || self =~ (/(true|t|yes|y|x|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

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
testcentricity_web-0.6.4.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.4.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.4 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.3 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.6.0 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.8 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.7.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.7.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.7 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.6 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.5 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.4 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.3 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.2 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.1 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.5.0 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.4.9 lib/testcentricity_web/utility_helpers.rb
testcentricity_web-0.4.8 lib/testcentricity_web/utility_helpers.rb