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

### Home Classes Methods

### In Files

- rdf/redland/stream.rb

### Parent

Object

### Methods

- ::create_finalizer
- ::new
- #context
- #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::Stream

This module provides a method to generate a stream of statements, suitable for outputing from RDF/XML parsers, returning as the results of queries and serialising models in order to manipulate them or transform into another syntax.

### Attributes

stream[RW]

### Public Class Methods

create_finalizer(stream) click to toggle source

You shouldn't use this. Used internally for cleanup.

    # File rdf/redland/stream.rb, line 22
    def Stream.create_finalizer(stream)
      proc {|id| # "Finalizer on #{id}"
        #puts "closing stream"
        Redland::librdf_free_stream(stream)
      }
    end

new(object,model) click to toggle source

Create a wrapper for a librdf_stream object (?? confirm)

    # File rdf/redland/stream.rb, line 15
    def initialize(object,model)
      @stream = object
      @model = model
      ObjectSpace.define_finalizer(self,Stream.create_finalizer(@stream))
    end

### Public Instance Methods

context() click to toggle source

Get the context of the current Statement in the stream

    # File rdf/redland/stream.rb, line 62
    def context()
      if not self.stream
        return true
      end
      my_node = Redland.librdf_stream_get_context(@stream)
      if not my_node
        return nil
      else
        return Node.new(:from_object=>my_node)
      end
    end

current() click to toggle source

Get the current Statement in the stram

    # File rdf/redland/stream.rb, line 39
    def current
      if not self.stream
        return nil
      end
      my_statement = Redland.librdf_stream_get_object(self.stream)

      unless my_statement
        return nil
      else
        return Statement.new(:from_object=>my_statement,:model=>@model)
      end
    end

end?() click to toggle source

Test if the stream has ended

    # File rdf/redland/stream.rb, line 30
    def end?
      if not @stream
        return true
      else
        return (Redland.librdf_stream_end(self.stream) != 0)
      end
    end

next() click to toggle source

Move to the next Statement in the stream

    # File rdf/redland/stream.rb, line 53
    def next()
      if not self.stream
        return true
      else
        return Redland.librdf_stream_next(self.stream)
      end
    end

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

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