Method: BBC::Programmes.fetch
- Defined in:
- lib/bbc/programmes.rb
.fetch(identifier) ⇒ Object
Load a subject into the local repository
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/bbc/programmes.rb', line 75 def self.fetch(identifier) unless identifier.is_a?(RDF::URI) identifier = RDF::URI("#{BASE_URI}/#{identifier}") end graph = self.http_get_graph(identifier) type = graph.first_object([identifier, RDF.type, nil]) raise "No type found for #{identifier}" if type.nil? klass = BBC::Programmes::Base.subclasses.find { |k| k.type == type } raise "No class found for #{identifier} of type #{type}" if klass.nil? # Add the graph to the repository of the type graph.each_statement do |s| klass.repository << s end klass.for(identifier) end |