Class: Formulary::QHPImporter
- Inherits:
-
Object
- Object
- Formulary::QHPImporter
- Defined in:
- lib/formulary/qhp_importer.rb
Overview
This class reads QHP data from a list of urls and loads it into a repository
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Instance Method Summary collapse
- #import ⇒ Object
-
#initialize(urls, repo) ⇒ QHPImporter
constructor
A new instance of QHPImporter.
- #qhp_json ⇒ Object
Constructor Details
#initialize(urls, repo) ⇒ QHPImporter
Returns a new instance of QHPImporter.
10 11 12 13 |
# File 'lib/formulary/qhp_importer.rb', line 10 def initialize(urls, repo) @urls = urls @repo = repo end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
8 9 10 |
# File 'lib/formulary/qhp_importer.rb', line 8 def repo @repo end |
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
8 9 10 |
# File 'lib/formulary/qhp_importer.rb', line 8 def urls @urls end |
Instance Method Details
#import ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/formulary/qhp_importer.rb', line 15 def import urls.each do |url| qhp_raw_data = HTTParty.get(url, verify: false) # FIXME qhp_json.concat(JSON.parse(qhp_raw_data, symbolize_names: true)) end repo.import(qhp_json) end |
#qhp_json ⇒ Object
23 24 25 |
# File 'lib/formulary/qhp_importer.rb', line 23 def qhp_json @qhp_json ||= [] end |