Class: String

Inherits:
Object show all
Includes:
Gamefic::Keywords
Defined in:
lib/gamefic/serialize.rb,
lib/gamefic/core_ext/string.rb

Constant Summary

Constants included from Gamefic::Keywords

Gamefic::Keywords::SPLIT_REGEXP

Instance Method Summary collapse

Methods included from Gamefic::Keywords

#keywords, #specified?

Instance Method Details

#cap_firstString

An alias for #capitalize_first.

Returns:



15
16
17
# File 'lib/gamefic/core_ext/string.rb', line 15

def cap_first
  self.capitalize_first
end

#capitalize_firstString

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

Returns:

  • (String)

    The capitalized text



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

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

#split_wordsArray

Get an array of words split by any whitespace.

Returns:



22
23
24
# File 'lib/gamefic/core_ext/string.rb', line 22

def split_words
  self.gsub(/[\s]+/, ' ').strip.split
end

#to_serialObject



36
37
38
# File 'lib/gamefic/serialize.rb', line 36

def to_serial
  self
end