Class: Ddr::Vocab::RDFVocabularyParser
- Inherits:
-
Object
- Object
- Ddr::Vocab::RDFVocabularyParser
- Defined in:
- lib/ddr/vocab/rdf_vocabulary_parser.rb
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #graph ⇒ Object
-
#initialize(source, prefix = "") ⇒ RDFVocabularyParser
constructor
A new instance of RDFVocabularyParser.
- #properties ⇒ Object
- #properties_query ⇒ Object
- #term_names ⇒ Object
- #term_symbols ⇒ Object
- #terms ⇒ Object
Constructor Details
#initialize(source, prefix = "") ⇒ RDFVocabularyParser
Returns a new instance of RDFVocabularyParser.
9 10 11 12 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 9 def initialize(source, prefix = "") @source = source @prefix = prefix end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
7 8 9 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 7 def prefix @prefix end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 7 def source @source end |
Instance Method Details
#graph ⇒ Object
39 40 41 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 39 def graph @graph ||= RDF::Graph.load(source).freeze end |
#properties ⇒ Object
26 27 28 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 26 def properties RDF::Query.execute(graph, properties_query) end |
#properties_query ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 30 def properties_query {:resource => { RDF.type => RDF.Property, RDF::RDFS.label => :label, RDF::RDFS.comment => :comment } } end |
#term_names ⇒ Object
14 15 16 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 14 def term_names @term_names ||= terms.collect { |t| t[:resource].to_s.sub(prefix, "") }.freeze end |
#term_symbols ⇒ Object
18 19 20 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 18 def term_symbols term_names.map(&:to_sym) end |
#terms ⇒ Object
22 23 24 |
# File 'lib/ddr/vocab/rdf_vocabulary_parser.rb', line 22 def terms properties.map(&:to_hash) end |