Class: RoadForest::TypeHandlers::RDFPost::Reader
- Inherits:
-
RDF::Reader
- Object
- RDF::Reader
- RoadForest::TypeHandlers::RDFPost::Reader
- Defined in:
- lib/roadforest/type-handlers/rdfpost.rb
Overview
Defined Under Namespace
Modules: St
Instance Attribute Summary collapse
-
#current_state ⇒ Object
Returns the value of attribute current_state.
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
-
#namespace_prefix ⇒ Object
Returns the value of attribute namespace_prefix.
-
#new_triple ⇒ Object
Returns the value of attribute new_triple.
-
#object ⇒ Object
Returns the value of attribute object.
-
#object_lang ⇒ Object
Returns the value of attribute object_lang.
-
#object_prefix ⇒ Object
Returns the value of attribute object_prefix.
-
#object_type ⇒ Object
Returns the value of attribute object_type.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#predicate_prefix ⇒ Object
Returns the value of attribute predicate_prefix.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#subject_prefix ⇒ Object
Returns the value of attribute subject_prefix.
Instance Method Summary collapse
- #build_triple ⇒ Object
- #consume_pair ⇒ Object
-
#initialize(input, options = nil, &block) ⇒ Reader
constructor
A new instance of Reader.
- #read_triple ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(input, options = nil, &block) ⇒ Reader
Returns a new instance of Reader.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 216 def initialize(input, =nil, &block) super(input, ||{}, &block) @lineno = 0 @new_triple = false @states = { :rdf => St::RDF.new(self), :def_ns_decl => St::DefNsDecl.new(self), :ns_decl => St::NsDecl.new(self), :ns_decl_suffix => St::NsDeclSuffix.new(self), :skip_to_subject => St::SkipToSubject.new(self), :skip_to_subj_or_pred => St::SkipToSubjectOrPred.new(self), :subject => St::Subject.new(self), :subject_suffix => St::SubjectSuffix.new(self), :predicate => St::Predicate.new(self), :predicate_suffix => St::PredicateSuffix.new(self), :object => St::Object.new(self), :object_suffix => St::ObjectSuffix.new(self), :object_literal => St::ObjectLiteral.new(self), :type_or_lang => St::TypeOrLang.new(self) } @current_state = @states.fetch(:rdf) end |
Instance Attribute Details
#current_state ⇒ Object
Returns the value of attribute current_state.
242 243 244 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 242 def current_state @current_state end |
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
241 242 243 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 241 def lineno @lineno end |
#namespace_prefix ⇒ Object
Returns the value of attribute namespace_prefix.
245 246 247 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 245 def namespace_prefix @namespace_prefix end |
#new_triple ⇒ Object
Returns the value of attribute new_triple.
243 244 245 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 243 def new_triple @new_triple end |
#object ⇒ Object
Returns the value of attribute object.
243 244 245 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 243 def object @object end |
#object_lang ⇒ Object
Returns the value of attribute object_lang.
244 245 246 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 244 def object_lang @object_lang end |
#object_prefix ⇒ Object
Returns the value of attribute object_prefix.
245 246 247 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 245 def object_prefix @object_prefix end |
#object_type ⇒ Object
Returns the value of attribute object_type.
244 245 246 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 244 def object_type @object_type end |
#predicate ⇒ Object
Returns the value of attribute predicate.
243 244 245 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 243 def predicate @predicate end |
#predicate_prefix ⇒ Object
Returns the value of attribute predicate_prefix.
245 246 247 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 245 def predicate_prefix @predicate_prefix end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
241 242 243 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 241 def states @states end |
#subject ⇒ Object
Returns the value of attribute subject.
243 244 245 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 243 def subject @subject end |
#subject_prefix ⇒ Object
Returns the value of attribute subject_prefix.
245 246 247 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 245 def subject_prefix @subject_prefix end |
Instance Method Details
#build_triple ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 263 def build_triple if @object.nil? or @predicate.nil? or @subject.nil? raise EOFError end object = @object if object.is_a? String object = ::RDF::Literal.new(object, :datatype => object_type, :language => object_lang) end @object_type = nil @object_lang = nil [@subject, @predicate, object] end |
#consume_pair ⇒ Object
282 283 284 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 282 def consume_pair @lineno += 1 end |
#read_triple ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 247 def read_triple if @lineno >= @input.length raise EOFError end while @lineno < @input.length @current_state.accept(*@input[@lineno]) if @new_triple @new_triple = false return build_triple end end return build_triple end |
#rewind ⇒ Object
278 279 280 |
# File 'lib/roadforest/type-handlers/rdfpost.rb', line 278 def rewind @lineno = 0 end |