ruby-rdf / rdf-vocab

Common RDF Vocabularies
The Unlicense
50 stars 29 forks source link

Ensure terms create methods that play nice with ruby #54

Closed cjcolvar closed 5 years ago

cjcolvar commented 6 years ago

Some terms in the Identities vocab end up with string names: https://github.com/ruby-rdf/rdf-vocab/blob/develop/lib/rdf/vocab/identifiers.rb#L174-L176

Expected Behavior

I'd hope for a nicer term like: ::RDF::Vocab::Identifiers.issue_number

Actual Behavior

To use this I need to send or call it:

::RDF::Vocab::Identifiers.send(:"issue-number")
::RDF::Vocab::Identifiers.method("issue-number").call
gkellogg commented 5 years ago

Sorry for the delay in responding.

I'm afraid that the ability to use the term directly, such as RDF::Vocab::DC.created is a convenience, because the term is compatible with Ruby procedure names. For other terms, such as issue-number it is incompatible. Creating some other lookup mechanism such as issue_number is not something anticipated, and the send or call is the best way to handle things where there may be such an issue. I'd consider a PR on RDF.rb RDF::Vocabulary that might support something like this, but it gets into many different aspects.