Class: RDF::XML::Reader

Inherits:
Reader
  • Object
show all
Defined in:
lib/xml/reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(input = $stdin, options = {}) {|_self| ... } ⇒ Reader

-

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
# File 'lib/xml/reader.rb', line 10

def initialize(input = $stdin, options = {}, &block)
  @input = input.respond_to?(:read) ? input.read : input
  @xml = ::Nokogiri::XML(@input)
  yield self if block_given?
end

Instance Method Details

#each_statement(&block) ⇒ Object

-


32
33
34
35
36
37
# File 'lib/xml/reader.rb', line 32

def each_statement(&block)
  return unless block_given?
  each_triple do |*triple|
    yield RDF::Statement.new(*triple)
  end
end

#each_triple(&block) ⇒ Object

-


19
20
21
22
23
24
25
26
27
# File 'lib/xml/reader.rb', line 19

def each_triple(&block)
  return unless block_given?
  if @xml.root.nil?
    raise RuntimeError, 'Malformed XML document'
  end
  @xml.root.subnodes.each do |node|
    parse_descriptions(node, &block)
  end
end