Class: RDF::Raptor::FFI::Writer
- Inherits:
-
Writer
- Object
- Writer
- RDF::Raptor::FFI::Writer
- Includes:
- Util::Logger
- Defined in:
- lib/rdf/raptor/ffi.rb
Overview
FFI writer implementation.
Constant Summary collapse
- ERROR_HANDLER =
Proc.new do |user_data, locator, | log_error() end
- WARNING_HANDLER =
Proc.new do |user_data, locator, | log_warn() end
Instance Attribute Summary collapse
-
#serializer ⇒ V2::Serializer
readonly
The Raptor serializer instance.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(output = $stdout, **options) {|writer| ... } ⇒ Writer
constructor
Initializes the FFI writer instance.
- #write_epilogue
- #write_prologue
- #write_term(value) ⇒ Object
- #write_triple(subject, predicate, object)
Constructor Details
#initialize(output = $stdout, **options) {|writer| ... } ⇒ Writer
Initializes the FFI writer instance.
159 160 161 162 163 164 165 166 |
# File 'lib/rdf/raptor/ffi.rb', line 159 def initialize(output = $stdout, **, &block) @format = self.class.format.rapper_format @serializer = V2::Serializer.new(@format) @serializer.error_handler = ERROR_HANDLER @serializer.warning_handler = WARNING_HANDLER @serializer.start_to(output, **) super end |
Instance Attribute Details
#serializer ⇒ V2::Serializer (readonly)
The Raptor serializer instance.
180 181 182 |
# File 'lib/rdf/raptor/ffi.rb', line 180 def serializer @serializer end |
Class Method Details
.serialize(value) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/rdf/raptor/ffi.rb', line 182 def self.serialize(value) output = StringIO.new writer = new(output) case value when nil then nil when FalseClass then value.to_s when RDF::Statement writer.write_triple(statement.subject, statement.predicate, statement.object) when RDF::Term writer.write_term(value) else raise ArgumentError, "expected an RDF::Statement or RDF::Term, but got #{value.inspect}" end output.to_s end |
Instance Method Details
#write_epilogue
This method returns an undefined value.
224 225 226 227 |
# File 'lib/rdf/raptor/ffi.rb', line 224 def write_epilogue @serializer.finish super end |
#write_prologue
This method returns an undefined value.
216 217 218 219 |
# File 'lib/rdf/raptor/ffi.rb', line 216 def write_prologue @serializer.prefix(self.prefixes) super end |
#write_term(value) ⇒ Object
209 210 211 |
# File 'lib/rdf/raptor/ffi.rb', line 209 def write_term(value) raise NotImplementedError end |
#write_triple(subject, predicate, object)
This method returns an undefined value.
205 206 207 |
# File 'lib/rdf/raptor/ffi.rb', line 205 def write_triple(subject, predicate, object) @serializer.serialize_triple(subject, predicate, object) end |