turtle.rb is a internal Ruby DSL for quickly generating RDF in the turtle format.
The following simple document
Turtle.build do prefix "http://kimdalsgaard.com/documents/" prefix :dc, "http://purl.org/dc/elements/1.1/" subject [_, "foo"], [:dc, "title"], "Foo" end
will produce the following result
@prefix : <http://kimdalsgaard.com/documents/> . @prefix dc: <http://purl.org/dc/elements/1.1/> . :foo dc:title "Foo" .
Turtle.build do prefix "http://kimdalsgaard.com/documents/" prefix :dc, "http://purl.org/dc/elements/1.1/" subject [_, "foo"] do predicate [:dc, "title"], "Foo" predicate [:dc, "creator"], "Kim Dalsgaard" end end
results in
@prefix : <http://kimdalsgaard.com/documents/> . @prefix dc: <http://purl.org/dc/elements/1.1/> . :foo dc:title "Foo" ; dc:creator "Kim Dalsgaard" .
Turtle.build do prefix :foaf, "http://xmlns.com/foaf/0.1/" subject ["http://dalsgaardkirk.com#kim"], [:foaf, "knows"] do object ["http://dalsgaardkirk.com#pernille"] object ["http://dalsgaardkirk.com#sophus"] end end
results in
@prefix foaf: <http://xmlns.com/foaf/0.1/> . <http://dalsgaardkirk.com#kim> foaf:knows <http://dalsgaardkirk.com#pernille> , <http://dalsgaardkirk.com#sophus> .
Turtle.build do prefix :foaf, "http://xmlns.com/foaf/0.1/" subject _("foo"), a, [:foaf, "Person"] subject _, a, [:foaf, "Person"] subject _, a, [:foaf, "Group"] subject :bar, a, [:foaf, "Group"] end
results in
@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:foo a foaf:Person . _:b0 a foaf:Person . _:b1 a foaf:Group . _:bar a foaf:Group .