Sha256: 66057eee09cac661da8077f6e58c8631aa9e3bff0fb3d82f9fc0e17919519fe4

Contents?: true

Size: 869 Bytes

Versions: 10

Compression:

Stored size: 869 Bytes

Contents

class String

  # Return true if the string is capitalized, otherwise false.
  #
  #   "THIS".capitalized?  #=> true
  #   "This".capitalized?  #=> true
  #   "this".capitalized?  #=> false
  #
  # CREDIT: Phil Tomson

  def capitalized?
    self =~ /^[A-Z]/
  end

  # Return true if the string is lowercase (downcase), otherwise false.
  #
  #   "THIS".downcase?  #=> false
  #   "This".downcase?  #=> false
  #   "this".downcase?  #=> true
  #
  # CREDIT: Phil Tomson

  def downcase?
    downcase == self
  end

  # Alias for #downcase? method.
  #alias_method :lowercase?, :downcase?

  # Is the string upcase/uppercase?
  #
  #   "THIS".upcase?  #=> true
  #   "This".upcase?  #=> false
  #   "this".upcase?  #=> false
  #
  # CREDIT: Phil Tomson

  def upcase?
    upcase == self
  end

  # Alias for #upcase? method.
  #alias_method :uppercase?, :upcase?

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/string/capitalized.rb
facets-2.8.3 lib/core/facets/string/capitalized.rb
facets-2.8.2 lib/core/facets/string/capitalized.rb
facets-2.8.1 lib/core/facets/string/capitalized.rb
facets-2.8.0 lib/core/facets/string/capitalized.rb
facets-2.7.0 lib/core/facets/string/capitalized.rb
facets-2.6.0 lib/core/facets/string/capitalized.rb
facets-2.5.1 lib/core/facets/string/capitalized.rb
facets-2.5.0 lib/core/facets/string/capitalized.rb
facets-2.5.2 lib/core/facets/string/capitalized.rb