Sha256: 46f31782fdec915925c10f2e99035e13dd1d41d1ea292f5456eceded8020d851

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

#--
# Credit goes to Phil Tomson.
#++
class String
  
  # Is the string upcase/uppercase?
  #
  #   require 'facet/string/case?'
  #
  #   "THIS".upcase?  #=> true
  #   "This".upcase?  #=> false
  #   "this".upcase?  #=> false
  #
  def upcase?
    self.upcase == self
  end
  alias_method( :uppercase?, :upcase? )
  
  # Is the string downcase/lowercase?
  #
  #   require 'facet/string/case?'
  #
  #   "THIS".downcase?  #=> false
  #   "This".downcase?  #=> false
  #   "this".downcase?  #=> true
  #
  def downcase?
    self.downcase == self
  end
  alias_method( :lowercase?, :downcase? )
  
  # Is the string capitalized?
  #
  #   require 'facet/string/case?'
  #
  #   "THIS".capitalized?  #=> true
  #   "This".capitalized?  #=> true
  #   "this".capitalized?  #=> false
  #  
  def capitalized?
    self.capitalize == self
  end

end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.6.3 lib/facet/string/case?.rb