Module: StringEnhancer

Defined in:
lib/string_enhancer.rb,
lib/string_enhancer/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.palindrome?(string) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/string_enhancer.rb', line 12

def self.palindrome?(string)
  processed = string.downcase.gsub(/\W/, "")
  processed == processed.reverse
end

.titleize(string) ⇒ Object



17
18
19
# File 'lib/string_enhancer.rb', line 17

def self.titleize(string)
  string.split.map(&:capitalize).join(' ')
end

.word_count(string) ⇒ Object



8
9
10
# File 'lib/string_enhancer.rb', line 8

def self.word_count(string)
  string.split.count
end