Sha256: 90f122d382ab969569444573ffe12e970bf7164403939af1c4c8d2dba6ac8710
Contents?: true
Size: 806 Bytes
Versions: 90
Compression:
Stored size: 806 Bytes
Contents
class Object # 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
90 entries across 87 versions & 20 rubygems