Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string.extend.rb
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#sanitize ⇒ Object
truncate.
-
#truncate(length = 30, truncate_string = "...") ⇒ Object
blank.
Instance Method Details
#blank? ⇒ Boolean
2 3 4 |
# File 'lib/string.extend.rb', line 2 def blank? self !~ /\S/ end |
#sanitize ⇒ Object
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(/<.*?>|⇒/, '') 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 |