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
Returns a new instance of IqvocDataset.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 10 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 IOError, Errno::ECONNREFUSED, Timeout::Error => e Rails.logger.error("Iqvoc source couldn't be resolved: #{@url}, message: #{e.}") ensure @name = fetch_name end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 8 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 8 def url @url end |
Instance Method Details
#alphabetical_search(prefix, locale) ⇒ Object
33 34 35 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 33 def alphabetical_search(prefix, locale) Dataset::Adaptors::Iqvoc::AlphabeticalSearchAdaptor.new(url).search(prefix, locale) end |
#find_label(concept_url) ⇒ Object
37 38 39 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 37 def find_label(concept_url) Dataset::Adaptors::Iqvoc::LabelAdaptor.new(url).find(concept_url) end |
#search(params) ⇒ Object
29 30 31 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 29 def search(params) Dataset::Adaptors::Iqvoc::SearchAdaptor.new(url).search(params) end |
#to_s ⇒ Object
25 26 27 |
# File 'app/models/dataset/iqvoc_dataset.rb', line 25 def to_s "#{name} (#{url})" end |