Class: Hotfile::Record::BKS24

Inherits:
Hotfile::Record show all
Defined in:
lib/hotfile/record/BKS24.rb

Overview

Ticket/Document Identification Record

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ BKS24

Returns a new instance of BKS24.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hotfile/record/BKS24.rb', line 7

def initialize(line)
  super

  coupon, conjunction, agent_code, issuance_reason, tour, transaction_code, destination, pnr, time, turnaround,
    reserved =
    line.scan(/
      ([A-Z0-9 ]{4})
      ([A-Z0-9 ]{3})
      (\d{8})
      ([A-Z0-9 ])
      ([A-Z0-9 ]{15})
      ([A-Z0-9]{4})
      ([A-Z0-9 ]{10})
      (.{13})
      ([\d ]{4})
      ([A-Z0-9 ]{5})
      (.{29})
    /x).flatten
  time = nil if time.strip == ''

  @data = {
    transaction_code: transaction_code,
    time: time&.insert(2, ':'),
    coupon: coupon.strip,
    conjunction: conjunction.strip,
    agent_code: agent_code.to_i,
    issuance_reason: issuance_reason.strip,
    tour: tour.strip,
    destination: destination.strip,
    pnr: pnr.strip,
    turnaround: turnaround.strip,
    reserved: reserved.strip
  }
end