Sha256: bee3f61567cf43b5685dd317a5bddbf00e854259b0460df45c446de5094445f4
Contents?: true
Size: 992 Bytes
Versions: 12
Compression:
Stored size: 992 Bytes
Contents
require 'linkeddata' class Dataset::IqvocDataset attr_reader :name, :url def initialize(url) @url = URI.parse(url) @repository = RDF::Repository.load(URI.join(url, 'dataset.rdf').to_s) rescue nil @name = fetch_name end def to_s "#{name} (#{url})" end def search(params) Dataset::Adaptors::Iqvoc::SearchAdaptor.new(url).search(params) end def alphabetical_search(prefix, locale) Dataset::Adaptors::Iqvoc::AlphabeticalSearchAdaptor.new(url).search(prefix, locale) end def find_label(concept_url) Dataset::Adaptors::Iqvoc::LabelAdaptor.new(url).find(concept_url) end private def fetch_name return 'unknown' if @repository.nil? void = RDF::Vocabulary.new('http://rdfs.org/ns/void#') query = RDF::Query.new({ dataset: { RDF.type => void.Dataset, RDF::DC.title => :title } }) results = query.execute(@repository) return 'unknown' if results.empty? results.map { |solution| solution.title.to_s }.first end end
Version data entries
12 entries across 12 versions & 1 rubygems