The iterator provides a generic way to receive a sequence of values (order may or may not be import) from objects, usually generated on demand.
You shouldn't use this. Used internally for cleanup.
# File rdf/redland/stream.rb, line 114 def NodeIterator.create_finalizer(iterator) proc {|id| # "Finalizer on #{id}" #puts "closing iterator" Redland::librdf_free_iterator(iterator) } end
# File rdf/redland/stream.rb, line 82 def initialize(object,model=nil,creator2=nil,creator3=nil) @iterator = object @model = model @creator2 = creator2 @creator3 = creator3 # Test if the iterator has finished def end?() return (Redland.librdf_iterator_end(@iterator) != 0) end # Get the current object from the iterator def current my_node = Redland.librdf_iterator_get_object(@iterator) if my_node == "NULL" or my_node == nil return nil elsif is_literal?(my_node) return Literal.from_node(my_node) else return Resource.new(my_node,@model) end end # Move to the next iterator element def next() my_node=Redland.librdf_iterator_next(@iterator) end ObjectSpace.define_finalizer(self,NodeIterator.create_finalizer(@iterator)) end
Get the current object from the iterator
# File rdf/redland/stream.rb, line 94 def current my_node = Redland.librdf_iterator_get_object(@iterator) if my_node == "NULL" or my_node == nil return nil elsif is_literal?(my_node) return Literal.from_node(my_node) else return Resource.new(my_node,@model) end end
(C) Copyright 2004-2013 Dave Beckett, (C) Copyright 2004-2005 University of Bristol