Sha256: cfe51765c802e63af52a6c75bc2240e5676aab93f919cd8f3523c3157e3572d4

Contents?: true

Size: 526 Bytes

Versions: 9

Compression:

Stored size: 526 Bytes

Contents

# frozen_string_literal: true

# Extensions to the core String class
class String
  unless method_defined?(:blank?) && ' '.blank?
    # Checks whether a string is blank. A string is considered blank if it
    # is either empty or contains only whitespace characters.
    #
    # @return [Boolean] true is the string is blank, false otherwise
    #
    # @example
    #   ''.blank?       #=> true
    #   '    '.blank?   #=> true
    #   '  test'.blank? #=> false
    def blank?
      empty? || lstrip.empty?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/core_ext/string.rb
rubocop-1.69.2 lib/rubocop/core_ext/string.rb
rubocop-1.69.1 lib/rubocop/core_ext/string.rb
rubocop-1.69.0 lib/rubocop/core_ext/string.rb
rubocop-1.68.0 lib/rubocop/core_ext/string.rb
rubocop-1.67.0 lib/rubocop/core_ext/string.rb
rubocop-1.66.1 lib/rubocop/core_ext/string.rb
rubocop-1.66.0 lib/rubocop/core_ext/string.rb
rubocop-1.65.1 lib/rubocop/core_ext/string.rb