Skip to content

Instantly share code, notes, and snippets.

@njh
Created May 24, 2010 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njh/412440 to your computer and use it in GitHub Desktop.
Save njh/412440 to your computer and use it in GitHub Desktop.
#!/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
@artob
Copy link

artob commented May 24, 2010

Note that you don't need the RDF:: qualifier for class names within the Person definition, since Spira::Resource includes the RDF module. So for example RDF::FOAF.name can be written simply as FOAF.name.

Also, instead of saying RDF::URI.parse("http://www.example.com/foo/") you can with recent RDF.rb versions just say RDF::URI("http://www.example.com/foo/").

If you include the RDF module globally (right after the require statements), then you can of course drop the RDF:: qualifiers altogether.

@njh
Copy link
Author

njh commented May 24, 2010

@njh
Copy link
Author

njh commented May 24, 2010

Thanks Arto :)

@datagraph
Copy link

Nick, see also http://github.com/datagraph/linkeddata which may come handy in DBpedia lite.

@njh
Copy link
Author

njh commented May 25, 2010

Reminds me of Bundle::* in CPAN :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment