Class: Relaton::Jis::Hit
- Inherits:
-
Core::Hit
- Object
- Core::Hit
- Relaton::Jis::Hit
- Defined in:
- lib/relaton/jis/hit.rb
Class Method Summary collapse
-
.create(hit, collection) ⇒ Relaton::Jis::Hit
Create new hit.
Instance Method Summary collapse
-
#eq?(ref_parts, year = nil, all_parts: false) ⇒ Boolean
Check if hit matches reference.
-
#id_parts ⇒ Hash
Return parts of document id.
- #item ⇒ Relaton::Jis::Item
Class Method Details
.create(hit, collection) ⇒ Relaton::Jis::Hit
Create new hit
14 15 16 |
# File 'lib/relaton/jis/hit.rb', line 14 def self.create(hit, collection) new hit, collection end |
Instance Method Details
#eq?(ref_parts, year = nil, all_parts: false) ⇒ Boolean
Check if hit matches reference
27 28 29 30 31 |
# File 'lib/relaton/jis/hit.rb', line 27 def eq?(ref_parts, year = nil, all_parts: false) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity part_match?(ref_parts, all_parts) && (year.nil? || year == id_parts[:year]) && expl_match?(ref_parts) && amd_match?(ref_parts) end |
#id_parts ⇒ Hash
Return parts of document id
38 39 40 |
# File 'lib/relaton/jis/hit.rb', line 38 def id_parts @id_parts ||= hit_collection.parse_ref hit[:id] end |
#item ⇒ Relaton::Jis::Item
43 44 45 46 47 48 49 50 51 |
# File 'lib/relaton/jis/hit.rb', line 43 def item @item ||= begin url = "#{HitCollection::GH_URL}#{hit[:file]}" resp = Net::HTTP.get_response URI(url) item = Item.from_yaml resp.body item.fetched = Date.today.to_s item end end |