Class: RelatonItu::Scrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_itu/scrapper.rb

Overview

Scrapper.

Constant Summary collapse

TYPES =
{
  "ISO" => "international-standard",
  "TS" => "technicalSpecification",
  "TR" => "technicalReport",
  "PAS" => "publiclyAvailableSpecification",
  "AWI" => "appruvedWorkItem",
  "CD" => "committeeDraft",
  "FDIS" => "finalDraftInternationalStandard",
  "NP" => "newProposal",
  "DIS" => "draftInternationalStandard",
  "WD" => "workingDraft",
  "R" => "recommendation",
  "Guide" => "guide",
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hit, imp: false) ⇒ Scrapper

Returns a new instance of Scrapper.



28
29
30
31
# File 'lib/relaton_itu/scrapper.rb', line 28

def initialize(hit, imp: false)
  @hit = hit
  @imp = imp
end

Instance Attribute Details

#hitObject (readonly)

Returns the value of attribute hit.



11
12
13
# File 'lib/relaton_itu/scrapper.rb', line 11

def hit
  @hit
end

#impObject (readonly)

Returns the value of attribute imp.



11
12
13
# File 'lib/relaton_itu/scrapper.rb', line 11

def imp
  @imp
end

Class Method Details

.parse_page(hit, imp: false) ⇒ Object



33
34
35
# File 'lib/relaton_itu/scrapper.rb', line 33

def self.parse_page(hit, imp: false)
  new(hit, imp: imp).parse_page
end

Instance Method Details

#parse_pageHash

Parse page.

Returns:

  • (Hash)


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/relaton_itu/scrapper.rb', line 39

def parse_page # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  return unless parser.doc

  ItuBibliographicItem.new(
    id: fetch_id,
    fetched: Date.today.to_s,
    type: "standard",
    docid: docid,
    edition: parser.fetch_edition,
    language: ["en"],
    script: ["Latn"],
    title: parser.fetch_titles,
    doctype: DocumentType.new(type: hit.hit[:type]),
    docstatus: parser.fetch_status,
    ics: [], # fetch_ics(doc),
    date: parser.fetch_dates,
    contributor: fetch_contributors,
    editorialgroup: parser.fetch_workgroup,
    abstract: parser.fetch_abstract,
    copyright: fetch_copyright,
    link: parser.fetch_link,
    relation: parser.fetch_relations,
    place: [RelatonBib::Place.new(city: "Geneva")],
  )
end