Sha256: 497ce3ddf239dbd14df9abb7fe6359e9617952700976180d3f801975b1983d43

Contents?: true

Size: 261 Bytes

Versions: 3

Compression:

Stored size: 261 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.2.pre.beta lib/locomotive/steam/core_ext/string.rb
locomotivecms_steam-0.1.1 lib/locomotive/steam/core_ext/string.rb
locomotivecms_steam-0.1.0 lib/locomotive/steam/core_ext/string.rb