Class: Dataset::IqvocDataset
- Inherits:
-
Object
- Object
- Dataset::IqvocDataset
- Defined in:
- app/models/dataset/iqvoc_dataset.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
2.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #alphabetical_search(prefix, locale) ⇒ Object
- #find_label(concept_url) ⇒ Object
-
#initialize(url) ⇒ IqvocDataset
constructor
A new instance of IqvocDataset.
- #search(params) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url) ⇒ IqvocDataset
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 9 def initialize(url) @url = URI.parse(url) dataset_url = URI.join(@url.to_s + '/', 'dataset.rdf') begin @repository = Timeout::timeout(DEFAULT_TIMEOUT) do RDF::Repository.load(dataset_url) end rescue Errno::ECONNREFUSED, Timeout::Error => e Rails.logger.error("Iqvoc source couldn't be resolved: #{@url}, message: #{e.message}") ensure @name = fetch_name end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 7 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 7 def url @url end |
Instance Method Details
#alphabetical_search(prefix, locale) ⇒ Object
32 33 34 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 32 def alphabetical_search(prefix, locale) Dataset::Adaptors::Iqvoc::AlphabeticalSearchAdaptor.new(url).search(prefix, locale) end |
#find_label(concept_url) ⇒ Object
36 37 38 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 36 def find_label(concept_url) Dataset::Adaptors::Iqvoc::LabelAdaptor.new(url).find(concept_url) end |
#search(params) ⇒ Object
28 29 30 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 28 def search(params) Dataset::Adaptors::Iqvoc::SearchAdaptor.new(url).search(params) end |
#to_s ⇒ Object
24 25 26 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 24 def to_s "#{name} (#{url})" end |