Sha256: 3b1f5227f11477dd55512525c400fa8cc0052699ba0c3be11423f2e933a23028

Contents?: true

Size: 872 Bytes

Versions: 7

Compression:

Stored size: 872 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

7 entries across 7 versions & 2 rubygems

Version Path
facets-2.4.0 lib/facets/string/capitalized.rb
facets-2.4.1 lib/facets/string/capitalized.rb
facets-2.4.3 lib/core/facets/string/capitalized.rb
facets-2.4.2 lib/core/facets/string/capitalized.rb
facets-2.4.4 lib/core/facets/string/capitalized.rb
facets-2.4.5 lib/core/facets/string/capitalized.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/string/capitalized.rb