Created
May 24, 2010 21:21
-
-
Save njh/412440 to your computer and use it in GitHub Desktop.
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 ruby | |
require 'rubygems' | |
require 'spira' | |
require 'rdf' | |
include RDF | |
class Person | |
include Spira::Resource | |
type FOAF.Person | |
base_uri "http://example.com/people/" | |
property :name, :predicate => FOAF.name, :type => String | |
property :homepage, :predicate => FOAF.homepage | |
end | |
person = Person.new(5) | |
person.name = "Joe Bloggs" | |
person.homepage = URI("http://www.example.com/foo/") | |
p person.name |
Thanks Arto :)
Nick, see also http://github.com/datagraph/linkeddata which may come handy in DBpedia lite.
Reminds me of Bundle::* in CPAN :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that you don't need the
RDF::
qualifier for class names within thePerson
definition, sinceSpira::Resource
includes theRDF
module. So for exampleRDF::FOAF.name
can be written simply asFOAF.name
.Also, instead of saying
RDF::URI.parse("http://www.example.com/foo/")
you can with recent RDF.rb versions just sayRDF::URI("http://www.example.com/foo/")
.If you include the
RDF
module globally (right after therequire
statements), then you can of course drop theRDF::
qualifiers altogether.