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

- (AbstractSerializer) initialize(graph)

New AbstractSerializer



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

- (String) base



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

def base
  @base
end

- (Graph) graph



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

def graph
  @graph
end

Instance Method Details

- (String) relativize(uri)

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



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

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