Sha256: 6b26e369f0539cd4130383b05e849a5c68ef9fdad86d73a90cba0f6f3ac36eff
Contents?: true
Size: 815 Bytes
Versions: 49
Compression:
Stored size: 815 Bytes
Contents
class Object #:nodoc: # An object is blank if it's false, empty, or a whitespace string. # For example, "", " ", +nil+, [], and {} are blank. # # This simplifies # # if !address.nil? && !address.empty? # # to # # if !address.blank? def blank? respond_to?(:empty?) ? empty? : !self end # An object is present if it's not blank. def present? !blank? end end class NilClass #:nodoc: def blank? true end end class FalseClass #:nodoc: def blank? true end end class TrueClass #:nodoc: def blank? false end end class Array #:nodoc: alias_method :blank?, :empty? end class Hash #:nodoc: alias_method :blank?, :empty? end class String #:nodoc: def blank? self !~ /\S/ end end class Numeric #:nodoc: def blank? false end end
Version data entries
49 entries across 49 versions & 14 rubygems