Sha256: f8822663ac2350c491e3ce9011bd997b5984bce7a3d333656d43676a19a9f840

Contents?: true

Size: 283 Bytes

Versions: 21

Compression:

Stored size: 283 Bytes

Contents

# -*- encoding : utf-8 -*-

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
redis-model-extension-0.1.0 lib/string_to_bool.rb