lib/noble_names.rb
# Upcases the first small letters in each word,
# seperated by hyphons.
# The word is also not capitalized if it already contains
# a capitalized letter. This is to allow Business Names
# to have custom capitalization.
# But beware, words seperated by spaces stay small.
# @return [String] the capitalized word.
# @example
#   capitalize('hans-ebert')  #=> 'Hans-Ebert'
#   capitalize('john')        #=> 'John'
#   capitalize('john james')  #=> 'John james'
#   capitalize('eBase')       #=> 'eBase'
Upcases the first small letters in each word,
seperated by hyphons.
The word is also not capitalized if it already contains
a capitalized letter. This is to allow Business Names
to have custom capitalization.
But beware, words seperated by spaces stay small.
Upcases the first small letters in each word seperated by hyphons . The word is also not capitalized if it already contains a capitalized letter . This is to allow Business Names to have custom capitalization . But beware words seperated by spaces stay small .
def capitalize(word)
      if word.match?(/[A-Z]|Ä|Ö|Ü/)
        word
      else
        word.gsub first_small_letters do |letter|
          upcase(letter)
        end
      end
    end
def capitalize ( word ) if word . match? ( / [A-Z]|Ä|Ö|Ü/) word else word . gsub first_small_letters do | letter | upcase ( letter ) end end end
Upcases the first small letters in each word,
seperated by hyphons.
Upcases the first small letters in each word seperated by hyphons .
the capitalized word.
the capitalized word .
String
word
<not_specific>
example
capitalize('hans-ebert') #=> 'Hans-Ebert' capitalize('john') #=> 'John' capitalize('john james') #=> 'John james' capitalize('eBase') #=> 'eBase'
capitalize ( ' hans - ebert ' ) # = > ' Hans - Ebert ' capitalize ( ' john ' ) # = > ' John ' capitalize ( ' john james ' ) # = > ' John james ' capitalize ( ' eBase ' ) # = > ' eBase '