Class: String

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

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/string.extend.rb', line 2

def blank?
  self !~ /\S/
end

#sanitizeObject

truncate



11
12
13
14
# File 'lib/string.extend.rb', line 11

def sanitize
  # strip html tags and html code of the arrow (=>)
  self.strip.gsub(/<.*?>|&#8658;/, '')
end

#truncate(length = 30, truncate_string = "...") ⇒ Object

blank



6
7
8
9
# File 'lib/string.extend.rb', line 6

def truncate(length = 30, truncate_string = "...")
  return if blank?
      (self.length > length ? self[0...(length - truncate_string.length)] + truncate_string : self).to_s
end