Class: String

Inherits:
Object show all
Defined in:
lib/helpers/string.rb

Instance Method Summary collapse

Instance Method Details

#dasherizeObject



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

def dasherize
  self.gsub(" ", "-").gsub("_", "-")
end

#includes_one_of?(arr) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/helpers/string.rb', line 25

def includes_one_of?(arr)
  tr = false
  arr.each do |el|
    tr ||= self.include?(el)
  end
  tr
end

#spacifyObject



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

def spacify
  self.gsub("-", " ").gsub("_", " ")
end

#titlecaseObject



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

def titlecase
  self.downcase.spacify.split(" ").collect {|str| str.capitalize}.join(" ")
end

#titleizeObject



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

def titleize
  titlecase
end

#underlineObject



21
22
23
# File 'lib/helpers/string.rb', line 21

def underline
  self.gsub(/\W/, "_")
end