How to define the prefix for a created vocabulary?

The .qname() method on URI is quite handy, but it relies on knowing
the __prefix__ for a vocabulary. For vocabs that I define in my code,
the constructor takes the base URI of the vocabulary, but I can't see
any way to define the __prefix__. Am I missing something?

For reference, my use case is that I'm creating constants in my code
to interact with a remote RDF store (i.e. I'm not loading files of
triples into my Ruby code, which is how I think the prefix usually
gets set on a vocabulary):

COMMON = RDF::Vocabulary.new( "http://foo.bar.com/common/" )
MAN = COMMON.man
FANFARE = COMMON.fanfare

This all works very nicely. Later, I'd like to create a slug for the
resources I'm using, which basically comes down to the local name of
the resource:

def slug( uri_resource )
  uri_resource.qname.second
end

Only at the moment, FANFARE.qname returns nil because the common vocab
doesn't have a __prefix__

Thanks,
Ian

Received on Wednesday, 20 April 2016 09:15:34 UTC