Sha256: c90211bf42d03232eff995e641e6638e147a7bff03b78034e323b0cd02a25a4c
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'rdf/rdfxml/patches/graph_properties' module RDF class Graph # Returns ordered rdf:_n objects or rdf:first, rdf:rest for a given subject def seq(subject) props = properties(subject) rdf_type = (props[RDF.type.to_s] || []).map {|t| t.to_s} #puts "seq; #{rdf_type} #{rdf_type - [RDF.Seq, RDF.Bag, RDF.Alt]}" if !(rdf_type - [RDF.Seq, RDF.Bag, RDF.Alt]).empty? props.keys.select {|k| k.match(/#{RDF._}(\d)$/)}. sort_by {|i| i.sub(RDF._.to_s, "").to_i}. map {|key| props[key]}. flatten elsif !self.query(:subject => subject, :predicate => RDF.first).empty? # N3-style first/rest chain list = [] while subject != RDF.nil props = properties(subject) f = props[RDF.first.to_s] if f.to_s.empty? || f.first == RDF.nil subject = RDF.nil else list += f subject = props[RDF.rest.to_s].first end end list else [] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rdf-rdfxml-0.2.3 | lib/rdf/rdfxml/patches/seq.rb |
rdf-rdfxml-0.2.2.1 | lib/rdf/rdfxml/patches/seq.rb |
rdf-rdfxml-0.2.2 | lib/rdf/rdfxml/patches/seq.rb |