Class: String

Inherits:
Object
  • Object
show all
Includes:
Gamefic::Matchable
Defined in:
lib/gamefic/core_ext/string.rb

Constant Summary

Constants included from Gamefic::Matchable

Gamefic::Matchable::SPLIT_REGEXP

Instance Method Summary collapse

Methods included from Gamefic::Matchable

#keywords, #match?

Instance Method Details

#cap_firstString

Returns:



9
10
11
# File 'lib/gamefic/core_ext/string.rb', line 9

def cap_first
  self.capitalize_first
end

#capitalize_firstObject

Capitalize the first letter without changing the rest of the string. (String#capitalize makes the rest of the string lower-case.)



5
6
7
# File 'lib/gamefic/core_ext/string.rb', line 5

def capitalize_first
  "#{self[0,1].upcase}#{self[1,self.length]}"
end

#split_wordsArray

Returns:



13
14
15
# File 'lib/gamefic/core_ext/string.rb', line 13

def split_words
  self.gsub(/ +/, ' ').strip.split
end