Class: Relaton::Jis::Hit

Inherits:
Core::Hit
  • Object
show all
Defined in:
lib/relaton/jis/hit.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(hit, collection) ⇒ Relaton::Jis::Hit

Create new hit

Parameters:

Returns:



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

Parameters:

  • ref_parts (Hash)

    parts of reference

  • year (String, nil) (defaults to: nil)

    year

  • all_parts (Boolean) (defaults to: false)

    check all parts of reference

Returns:

  • (Boolean)

    true 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_partsHash

Return parts of document id

Returns:

  • (Hash)

    hash with 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

#itemRelaton::Jis::Item

Returns:



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