Class: SaxStream::Internal::ElementStack::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/sax_stream/internal/element_stack.rb

Direct Known Subclasses

RootElement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attrs) ⇒ Element

Returns a new instance of Element.



9
10
11
12
13
# File 'lib/sax_stream/internal/element_stack.rb', line 9

def initialize(name, attrs)
  @name = name
  @attrs = attrs
  @content = nil
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/sax_stream/internal/element_stack.rb', line 7

def name
  @name
end

Instance Method Details

#attributes(prefix = nil) ⇒ Object



15
16
17
18
19
20
# File 'lib/sax_stream/internal/element_stack.rb', line 15

def attributes(prefix = nil)
  prefix ||= @name
  @attrs.map do |key, value|
    ["#{prefix}/@#{key}", value]
  end
end

#contentObject



26
27
28
# File 'lib/sax_stream/internal/element_stack.rb', line 26

def content
  @content
end

#record_characters(string) ⇒ Object



30
31
32
33
# File 'lib/sax_stream/internal/element_stack.rb', line 30

def record_characters(string)
  @content ||= ''
  @content += string
end

#relative_attributesObject



22
23
24
# File 'lib/sax_stream/internal/element_stack.rb', line 22

def relative_attributes
  @attrs
end