Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/string_helper.rb

Instance Method Summary collapse

Instance Method Details

#capitalize_firstObject



5
6
7
8
# File 'lib/string_helper.rb', line 5

def capitalize_first
    self[0, 1].upcase + self[1..-1]
    self
end

#strip_html(*preserve_tags) ⇒ Object



10
11
12
13
14
# File 'lib/string_helper.rb', line 10

def strip_html(*preserve_tags)
   html = self.strip || ''
   preserve_array = preserve_tags.join('|') << '|\/'
   html.gsub(/<(\/|\s)*[^(#{preserve_array})][^>]*>/,'').squeeze(" ").strip
end