Class: Nori::Parser::Nokogiri::Document

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/nori/parser/nokogiri.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



12
13
14
# File 'lib/nori/parser/nokogiri.rb', line 12

def options
  @options
end

Instance Method Details

#characters(string) ⇒ Object Also known as: cdata_block



29
30
31
# File 'lib/nori/parser/nokogiri.rb', line 29

def characters(string)
  stack.last.add_node(string) unless string.strip.length == 0 || stack.empty?
end

#end_element(name) ⇒ Object



22
23
24
25
26
27
# File 'lib/nori/parser/nokogiri.rb', line 22

def end_element(name)
  if stack.size > 1
    last = stack.pop
    stack.last.add_node last
  end
end

#stackObject



14
15
16
# File 'lib/nori/parser/nokogiri.rb', line 14

def stack
  @stack ||= []
end

#start_element(name, attrs = []) ⇒ Object



18
19
20
# File 'lib/nori/parser/nokogiri.rb', line 18

def start_element(name, attrs = [])
  stack.push Nori::XMLUtilityNode.new(options, name, Hash[*attrs.flatten])
end