Sha256: 50c7d746d1911a4fcdc2b8d9611d116a3dd952f8e6439df03c04a8d24835f8b7
Contents?: true
Size: 724 Bytes
Versions: 25
Compression:
Stored size: 724 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 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
25 entries across 25 versions & 7 rubygems