Class String
In: raggle  (CVS)
Parent: Object

String utility methods #

Methods

Public Instance methods

Return a copy of this string with quotes and backslashes escaped.

Example:

  'a\b'.escape #=> 'a\\b'

Escape the quotes and backslashes in this string. Returns self.

Example:

  'a\b'.escape! #=> 'a\\b'

Return a copy of this string with ’%’ characters escaped.

Example:

  'a%b'.escape_format #=> 'a%%b'

Escape ’%’ characters in this string. Returns self.

Example:

  a = 'a%b'.escape_format!
  a.escape_format!
  a #=> 'a%%b'

return a copy of this string with HTML special characters escaped

Example:

  str = '<b>Rip &amp "Burn"</b>'.escape_html
  str #=> "&lt;b&gt;Rip &amp;amp &quot;Burn&quot;&lt;/b&gt;"

Get the number of lines in this string.

Example:

 "a\nb".lines #=> 2

Return copy of string with lines reflowed for the given terminal width.

Example:

  str = "this is a really long string it won't fit"
  str.reflow(22) #=> "this is a really long\nstring it won't fit"

Return copy of string with all HTML tags stripped.

Example:

  "<a href='sadf'>blargh</a>".strip_tags #=> 'blargh'

Return copy of string with HTML entities converted into ASCII characters.

Note: this bit of love is originally from the pickaxe (augmented by me, of course).

Example:

  '&amp;&lt;br /&gt;'.unescape_html #=> '&<br />'

[Validate]