Class: XmlParsable::Elements::StringElement

Inherits:
AbstractElement show all
Defined in:
lib/xmlparsable/elements/string.rb

Overview

Parses content into a ruby String value. This discards comments and children elements so “abc <!– foo –> def whatever” is read as “abc def”

Defined Under Namespace

Classes: String

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElement

#comment, #open, parsable

Constructor Details

#initialize(name, attributes, parent, arguments) ⇒ StringElement

Returns a new instance of StringElement.



15
16
17
18
# File 'lib/xmlparsable/elements/string.rb', line 15

def initialize(name, attributes, parent, arguments)
  @name, @attributes, @parent, @string =
    name, attributes, parent, String.new
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/xmlparsable/elements/string.rb', line 13

def name
  @name
end

Instance Method Details

#finalizeObject



24
25
26
27
# File 'lib/xmlparsable/elements/string.rb', line 24

def finalize
  @string.instance_variable_set(:@xmlattrs, @attributes)
  @parent.close(self, @string)
end

#read(text) ⇒ Object



20
21
22
# File 'lib/xmlparsable/elements/string.rb', line 20

def read(text)
  @string << text
end