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