Redland RDF Language Bindings - Ruby RDoc - Class: Redland::NodeIterator

### Home Classes Methods

### In Files

- rdf/redland/stream.rb

### Parent

Object

### Methods

- ::create_finalizer
- ::new
- #current
- #end?
- #next

### Included Modules

- Redland::Util

### Files

- Makefile
- Makefile
- Makefile
- Makefile

### Class/Module Index

Quicksearch

- Redland
- Redland::BNode
- Redland::ContextParser
- Redland::FileStore
- Redland::HashOpen
- Redland::HashStore
- Redland::Literal
- Redland::MemoryStore
- Redland::MergedModel
- Redland::Model
- Redland::Namespace
- Redland::Node
- Redland::NodeIterator
- Redland::NodeTypeError
- Redland::OWL
- Redland::Parser
- Redland::Query
- Redland::QueryResults
- Redland::RDFS
- Redland::RedlandError
- Redland::Resource
- Redland::Serializer
- Redland::Statement
- Redland::Stream
- Redland::TripleStore
- Redland::Uri
- Redland::Util
- Redland::World
- DC
- FOAF

No matching classes.

# Redland::NodeIterator

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.

### Public Class Methods

create_finalizer(iterator) click to toggle source

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

new(object,model=nil,creator2=nil,creator3=nil) click to toggle source

    # 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

### Public Instance Methods

current() click to toggle source

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

end?() click to toggle source

Test if the iterator has finished

    # File rdf/redland/stream.rb, line 89
    def end?()
      return (Redland.librdf_iterator_end(@iterator) != 0)
    end

next() click to toggle source

Move to the next iterator element

    # File rdf/redland/stream.rb, line 106
    def next()
      my_node=Redland.librdf_iterator_next(@iterator)
    end

Go to Redland Home - Language Bindings Home - Ruby API Home

(C) Copyright 2004-2013 Dave Beckett, (C) Copyright 2004-2005 University of Bristol