lib/facet/string/capitalized.rb in facets-0.9.0 vs lib/facet/string/capitalized.rb in facets-1.0.0
- old
+ new
@@ -1,37 +1,74 @@
-require 'nano/string/capitalized.rb'
\ No newline at end of file
+
+class String
+
+ # Return true if the string is capitalized, otherwise false.
+ #
+ # "THIS".capitalized? #=> true
+ # "This".capitalized? #=> true
+ # "this".capitalized? #=> false
+ #
+ #--
+ # Credit goes to Phil Tomson.
+ #++
+ def capitalized?
+ self =~ /^[A-Z]/
+ end
+
+end #class String
+
+
+# _____ _
+# |_ _|__ ___| |_
+# | |/ _ \/ __| __|
+# | | __/\__ \ |_
+# |_|\___||___/\__|
+#
+=begin test
+
+ require 'test/unit'
+
+ class TCString < Test::Unit::TestCase
+
+ def test_capitalized?
+ assert( 'Abc'.capitalized? )
+ end
+
+ end
+
+=end