Class: String

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

Overview

Extensions to the built-in String class

Instance Method Summary collapse

Instance Method Details

#xmlsafeObject

Returns a copy of the string with all &, < and > characters replaced by their equivalent XML entities (&amp;, &lt;, and &gt;)



690
691
692
# File 'lib/tagtreescanner.rb', line 690

def xmlsafe
  self.dup.xmlsafe!
end

#xmlsafe!Object

Modifies the string, replacing all &, < and > characters with their equivalent XML entities (&amp;, &lt;, and &gt;)



697
698
699
700
701
702
# File 'lib/tagtreescanner.rb', line 697

def xmlsafe!
  self.gsub!( /&/, '&amp;' )
  self.gsub!( /</, '&lt;' )
  self.gsub!( />/, '&gt;' )
  self
end