Class: Mindee::Product::FR::IdCard::IdCardV2Document

Inherits:
Mindee::Parsing::Common::Prediction show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/fr/id_card/id_card_v2_document.rb

Overview

Carte Nationale d’Identité API version 2.0 document data.

Direct Known Subclasses

IdCardV2PagePrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ IdCardV2Document

Returns a new instance of IdCardV2Document.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 60

def initialize(prediction, page_id)
  super()
  @alternate_name = StringField.new(prediction['alternate_name'], page_id)
  @authority = StringField.new(prediction['authority'], page_id)
  @birth_date = DateField.new(prediction['birth_date'], page_id)
  @birth_place = StringField.new(prediction['birth_place'], page_id)
  @card_access_number = StringField.new(prediction['card_access_number'], page_id)
  @document_number = StringField.new(prediction['document_number'], page_id)
  @expiry_date = DateField.new(prediction['expiry_date'], page_id)
  @gender = StringField.new(prediction['gender'], page_id)
  @given_names = []
  prediction['given_names'].each do |item|
    @given_names.push(StringField.new(item, page_id))
  end
  @issue_date = DateField.new(prediction['issue_date'], page_id)
  @mrz1 = StringField.new(prediction['mrz1'], page_id)
  @mrz2 = StringField.new(prediction['mrz2'], page_id)
  @mrz3 = StringField.new(prediction['mrz3'], page_id)
  @nationality = StringField.new(prediction['nationality'], page_id)
  @surname = StringField.new(prediction['surname'], page_id)
end

Instance Attribute Details

#alternate_nameMindee::Parsing::Standard::StringField (readonly)

The alternate name of the card holder.



14
15
16
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 14

def alternate_name
  @alternate_name
end

#authorityMindee::Parsing::Standard::StringField (readonly)

The name of the issuing authority.



17
18
19
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 17

def authority
  @authority
end

#birth_dateMindee::Parsing::Standard::DateField (readonly)

The date of birth of the card holder.



20
21
22
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 20

def birth_date
  @birth_date
end

#birth_placeMindee::Parsing::Standard::StringField (readonly)

The place of birth of the card holder.



23
24
25
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 23

def birth_place
  @birth_place
end

#card_access_numberMindee::Parsing::Standard::StringField (readonly)

The card access number (CAN).



26
27
28
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 26

def card_access_number
  @card_access_number
end

#document_numberMindee::Parsing::Standard::StringField (readonly)

The document number.



29
30
31
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 29

def document_number
  @document_number
end

#expiry_dateMindee::Parsing::Standard::DateField (readonly)

The expiry date of the identification card.



32
33
34
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 32

def expiry_date
  @expiry_date
end

#genderMindee::Parsing::Standard::StringField (readonly)

The gender of the card holder.



35
36
37
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 35

def gender
  @gender
end

#given_namesArray<Mindee::Parsing::Standard::StringField> (readonly)

The given name(s) of the card holder.



38
39
40
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 38

def given_names
  @given_names
end

#issue_dateMindee::Parsing::Standard::DateField (readonly)

The date of issue of the identification card.



41
42
43
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 41

def issue_date
  @issue_date
end

#mrz1Mindee::Parsing::Standard::StringField (readonly)

The Machine Readable Zone, first line.



44
45
46
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 44

def mrz1
  @mrz1
end

#mrz2Mindee::Parsing::Standard::StringField (readonly)

The Machine Readable Zone, second line.



47
48
49
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 47

def mrz2
  @mrz2
end

#mrz3Mindee::Parsing::Standard::StringField (readonly)

The Machine Readable Zone, third line.



50
51
52
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 50

def mrz3
  @mrz3
end

#nationalityMindee::Parsing::Standard::StringField (readonly)

The nationality of the card holder.



53
54
55
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 53

def nationality
  @nationality
end

#surnameMindee::Parsing::Standard::StringField (readonly)

The surname of the card holder.



56
57
58
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 56

def surname
  @surname
end

Instance Method Details

#to_sString

Returns:

  • (String)


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/mindee/product/fr/id_card/id_card_v2_document.rb', line 83

def to_s
  given_names = @given_names.join("\n #{' ' * 15}")
  out_str = String.new
  out_str << "\n:Nationality: #{@nationality}".rstrip
  out_str << "\n:Card Access Number: #{@card_access_number}".rstrip
  out_str << "\n:Document Number: #{@document_number}".rstrip
  out_str << "\n:Given Name(s): #{given_names}".rstrip
  out_str << "\n:Surname: #{@surname}".rstrip
  out_str << "\n:Alternate Name: #{@alternate_name}".rstrip
  out_str << "\n:Date of Birth: #{@birth_date}".rstrip
  out_str << "\n:Place of Birth: #{@birth_place}".rstrip
  out_str << "\n:Gender: #{@gender}".rstrip
  out_str << "\n:Expiry Date: #{@expiry_date}".rstrip
  out_str << "\n:Mrz Line 1: #{@mrz1}".rstrip
  out_str << "\n:Mrz Line 2: #{@mrz2}".rstrip
  out_str << "\n:Mrz Line 3: #{@mrz3}".rstrip
  out_str << "\n:Date of Issue: #{@issue_date}".rstrip
  out_str << "\n:Issuing Authority: #{@authority}".rstrip
  out_str[1..].to_s
end