class REXML::Text
def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
In the last example, the +entity_filter+ argument is ignored.
Text.new( "sean russell", false, nil, true, ["s"] ) #-> "sean russell"
Text.new( "sean russell", false, nil, false, ["s"] ) #-> "&s; russell"
supplied text. This argument is only useful if +raw+ is set to false.
+entity_filter+ (nil) This can be an array of entities to match in the
Text.new( "sean russell", false, nil, true ) #-> "sean russell"
Text.new( "sean russell" ) #-> "&s; &r;"
# and that the entity "r" is defined to be "russell"
# Assume that the entity "s" is defined to be "sean"
Text.new( "<&", false, nil, true ) #-> "<&"
Text.new( "<&", false, nil, true ) #-> Parse exception
Text.new( "<&", false, nil, false ) #-> "<&"
Text.new( "<&", false, nil, false ) #-> "<&"
want REXML to escape that text in output.
Use this field if you have entities defined for some text, and you don't
value for the parent, and no value is supplied, the default is false.
parent will be used as the raw value for this node. If there is no raw
text. If this value is nil (the default), then the raw value of the
escape any and all defined entities whose values are contained in the
this value is false, the string may contain any characters, and REXML will
contain no unescaped XML markup, and REXML will not change the text. If
If true, then the value of used to construct this object is expected to
+raw+ (nil) This argument can be given three values.
will be set to this.
+parent+ (nil) if this is a Parent object, the parent
respected
+respect_whitespace+ (boolean, false) if true, whitespace is
the object is shallowly cloned.
+arg+ if a String, the content is set to the String. If a Text,
Constructor
def initialize(arg, respect_whitespace=false, parent=nil, raw=nil, entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK ) @raw = false @parent = nil @entity_filter = nil if parent super( parent ) @raw = parent.raw end if arg.kind_of? String @string = arg.dup elsif arg.kind_of? Text @string = arg.instance_variable_get(:@string).dup @raw = arg.raw @entity_filter = arg.instance_variable_get(:@entity_filter) else raise "Illegal argument of type #{arg.type} for Text constructor (#{arg})" end @string.squeeze!(" \n\t") unless respect_whitespace @string.gsub!(/\r\n?/, "\n") @raw = raw unless raw.nil? @entity_filter = entity_filter if entity_filter clear_cache Text.check(@string, illegal, doctype) if @raw end