Class: RdfContext::AbstractSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf_context/serializer/abstract_serializer.rb

Overview

Abstract serializer

Direct Known Subclasses

NTSerializer, RecursiveSerializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ AbstractSerializer

New AbstractSerializer

Parameters:



13
14
15
16
# File 'lib/rdf_context/serializer/abstract_serializer.rb', line 13

def initialize(graph)
  @graph = graph
  @base = nil
end

Instance Attribute Details

#baseString

Returns:



8
9
10
# File 'lib/rdf_context/serializer/abstract_serializer.rb', line 8

def base
  @base
end

#graphGraph

Returns:



5
6
7
# File 'lib/rdf_context/serializer/abstract_serializer.rb', line 5

def graph
  @graph
end

Instance Method Details

#relativize(uri) ⇒ String

Create a relative version of the uri parameter if a base URI is defined

Parameters:

  • uri (#to_s)

Returns:



29
30
31
32
# File 'lib/rdf_context/serializer/abstract_serializer.rb', line 29

def relativize(uri)
  uri = uri.to_s
  self.base ? uri.sub(self.base, "") : uri
end

#serialize(stream, options = {})

This method returns an undefined value.

Serialize the graph

Parameters:

  • stream (IO, StreamIO)

    Stream in which to place serialized graph

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :base (URIRef, String) — default: nil

    Base URI of graph, used to shorting URI references



23
24
# File 'lib/rdf_context/serializer/abstract_serializer.rb', line 23

def serialize(stream, options = {})
end