Class: Mindee::Product::FR::IdCard::IdCardV1Document

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

Overview

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

Direct Known Subclasses

IdCardV1PagePrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ IdCardV1Document

Returns a new instance of IdCardV1Document.

Parameters:

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


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/mindee/product/fr/id_card/id_card_v1_document.rb', line 45

def initialize(prediction, page_id)
  super
  @authority = Parsing::Standard::StringField.new(
    prediction['authority'],
    page_id
  )
  @birth_date = Parsing::Standard::DateField.new(
    prediction['birth_date'],
    page_id
  )
  @birth_place = Parsing::Standard::StringField.new(
    prediction['birth_place'],
    page_id
  )
  @expiry_date = Parsing::Standard::DateField.new(
    prediction['expiry_date'],
    page_id
  )
  @gender = Parsing::Standard::StringField.new(
    prediction['gender'],
    page_id
  )
  @given_names = [] # : Array[Parsing::Standard::StringField]
  prediction['given_names'].each do |item|
    @given_names.push(Parsing::Standard::StringField.new(item, page_id))
  end
  @id_number = Parsing::Standard::StringField.new(
    prediction['id_number'],
    page_id
  )
  @mrz1 = Parsing::Standard::StringField.new(prediction['mrz1'], page_id)
  @mrz2 = Parsing::Standard::StringField.new(prediction['mrz2'], page_id)
  @surname = Parsing::Standard::StringField.new(
    prediction['surname'],
    page_id
  )
end

Instance Attribute Details

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

The name of the issuing authority.



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

def authority
  @authority
end

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

The date of birth of the card holder.



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

def birth_date
  @birth_date
end

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

The place of birth of the card holder.



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

def birth_place
  @birth_place
end

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

The expiry date of the identification card.



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

def expiry_date
  @expiry_date
end

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

The gender of the card holder.



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

def gender
  @gender
end

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

The given name(s) of the card holder.



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

def given_names
  @given_names
end

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

The identification card number.



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

def id_number
  @id_number
end

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

Machine Readable Zone, first line



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

def mrz1
  @mrz1
end

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

Machine Readable Zone, second line



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

def mrz2
  @mrz2
end

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

The surname of the card holder.



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

def surname
  @surname
end

Instance Method Details

#to_sString

Returns:

  • (String)


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

def to_s
  given_names = @given_names.join("\n #{' ' * 15}")
  out_str = String.new
  out_str << "\n:Identity Number: #{@id_number}".rstrip
  out_str << "\n:Given Name(s): #{given_names}".rstrip
  out_str << "\n:Surname: #{@surname}".rstrip
  out_str << "\n:Date of Birth: #{@birth_date}".rstrip
  out_str << "\n:Place of Birth: #{@birth_place}".rstrip
  out_str << "\n:Expiry Date: #{@expiry_date}".rstrip
  out_str << "\n:Issuing Authority: #{@authority}".rstrip
  out_str << "\n:Gender: #{@gender}".rstrip
  out_str << "\n:MRZ Line 1: #{@mrz1}".rstrip
  out_str << "\n:MRZ Line 2: #{@mrz2}".rstrip
  out_str[1..].to_s
end