Class: ODDB::OdbaExporter::PatentXls

Inherits:
Object
  • Object
show all
Defined in:
ext/export/src/patent_xls.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PatentXls

Returns a new instance of PatentXls.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'ext/export/src/patent_xls.rb', line 10

def initialize(path)
  @workbook = Spreadsheet::Excel.new(path)
  @fmt_title = Spreadsheet::Format.new(:bold=>true)
  @worksheet = @workbook.add_worksheet("Patentablauf")
  columns = [
    'Bezeichnung', 
    'Swissmedic-Nr.', 'Registrierungsdatum Swissmedic', 
    'ESZ-Nr.', 'Anmeldedatum', 'Publikationsdatum', 'Erteilungsdatum', 
    'Schutzdauerbeginn', 'Ablaufdatum', 'Löschdatum',
    'Grund-Patent-Nr.', 'Schutzbeginn Grund-Patent', 'Direktlink',
  ]
  @worksheet.write(0, 0, columns, @fmt_title)
  @rows = 1
end

Instance Method Details

#closeObject



24
25
26
# File 'ext/export/src/patent_xls.rb', line 24

def close
  @workbook.close
end

#date(date) ⇒ Object



27
28
29
30
31
# File 'ext/export/src/patent_xls.rb', line 27

def date(date)
  if(date)
    date.strftime('%d.%m.%Y')
  end
end

#export(odba_ids, nil_data) ⇒ Object



32
33
34
35
36
37
38
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
64
65
# File 'ext/export/src/patent_xls.rb', line 32

def export(odba_ids, nil_data)
  url_base = "http://ch.oddb.org/de/gcc/resolve/pointer/"
  odba_ids.each { |id|
    reg = ODBA.cache.fetch(id)
    pat = reg.patent
    row = []
    if reg.name_base != nil
      row = [
        reg.name_base[/^.\D+/u], reg.iksnr, date(reg.registration_date),
        pat.certificate_number, date(pat.registration_date), 
        date(pat.publication_date), date(pat.issue_date), 
        date(pat.protection_date), date(pat.expiry_date), 
        date(pat.deletion_date),
        pat.base_patent, date(pat.base_patent_date),
      ]
    else
      row = [
        "nil", reg.iksnr, date(reg.registration_date),
        pat.certificate_number, date(pat.registration_date), 
        date(pat.publication_date), date(pat.issue_date), 
        date(pat.protection_date), date(pat.expiry_date), 
        date(pat.deletion_date),
        pat.base_patent, date(pat.base_patent_date),
      ]
      nil_data << row.join(", ").to_s
    end
    @worksheet.write(@rows, 0, row)
    if(pac = reg.active_packages.sort_by { |pac| pac.ikscd }.first)
      @worksheet.write_url(@rows, row.size, url_base + pac.pointer.to_s)
    end
    @rows += 1
  }
  @rows
end