Created
October 22, 2010 23:09
-
-
Save artob/641535 to your computer and use it in GitHub Desktop.
RDF.rb 0.3.0 BGP query example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9 | |
require 'rdf' | |
require 'rdf/ntriples' | |
RDF::Repository.load('http://rdf.rubyforge.org/doap.nt') do |rdf| | |
bgp = RDF::Query.new do | |
self << [:person, RDF.type, RDF::FOAF.Person] | |
self << [:person, RDF::FOAF.name, :name] | |
self << [:person, RDF::FOAF.mbox, :email] | |
end | |
bgp.execute(rdf).each do |solution| | |
p solution.to_hash | |
end | |
end | |
#=> {:person => #<RDF::URI(http://ar.to/#self)>, | |
#=> :name => #<RDF::Literal("Arto Bendiken")> | |
#=> :email => #<RDF::URI(mailto:[email protected])>} | |
#=> {:person => #<RDF::URI(http://bhuga.net/#ben)>, | |
#=> :name => #<RDF::Literal("Ben Lavender")> | |
#=> :email => #<RDF::URI(mailto:[email protected])>} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment