Class: Mindee::V1::Product::Passport::PassportV1Document
- Inherits:
-
Mindee::V1::Parsing::Common::Prediction
- Object
- Mindee::V1::Parsing::Common::Prediction
- Mindee::V1::Product::Passport::PassportV1Document
- Includes:
- Mindee::V1::Parsing::Standard
- Defined in:
- lib/mindee/v1/product/passport/passport_v1_document.rb
Overview
Passport API version 1.1 document data.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#birth_date ⇒ Mindee::V1::Parsing::Standard::DateField
readonly
The date of birth of the passport holder.
-
#birth_place ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The place of birth of the passport holder.
-
#country ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The country's 3 letter code (ISO 3166-1 alpha-3).
-
#expiry_date ⇒ Mindee::V1::Parsing::Standard::DateField
readonly
The expiry date of the passport.
-
#gender ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The gender of the passport holder.
-
#given_names ⇒ Array<Mindee::V1::Parsing::Standard::StringField>
readonly
The given name(s) of the passport holder.
-
#id_number ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The passport's identification number.
-
#issuance_date ⇒ Mindee::V1::Parsing::Standard::DateField
readonly
The date the passport was issued.
-
#mrz1 ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
Machine Readable Zone, first line.
-
#mrz2 ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
Machine Readable Zone, second line.
-
#surname ⇒ Mindee::V1::Parsing::Standard::StringField
readonly
The surname of the passport holder.
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ PassportV1Document
constructor
A new instance of PassportV1Document.
- #to_s ⇒ String
Constructor Details
#initialize(prediction, page_id) ⇒ PassportV1Document
Returns a new instance of PassportV1Document.
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 82 83 84 85 86 87 88 89 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 49 def initialize(prediction, page_id) super @birth_date = Parsing::Standard::DateField.new( prediction['birth_date'], page_id ) @birth_place = Parsing::Standard::StringField.new( prediction['birth_place'], page_id ) @country = Parsing::Standard::StringField.new( prediction['country'], 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 ) @issuance_date = Parsing::Standard::DateField.new( prediction['issuance_date'], 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
#birth_date ⇒ Mindee::V1::Parsing::Standard::DateField (readonly)
The date of birth of the passport holder.
15 16 17 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 15 def birth_date @birth_date end |
#birth_place ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The place of birth of the passport holder.
18 19 20 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 18 def birth_place @birth_place end |
#country ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The country's 3 letter code (ISO 3166-1 alpha-3).
21 22 23 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 21 def country @country end |
#expiry_date ⇒ Mindee::V1::Parsing::Standard::DateField (readonly)
The expiry date of the passport.
24 25 26 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 24 def expiry_date @expiry_date end |
#gender ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The gender of the passport holder.
27 28 29 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 27 def gender @gender end |
#given_names ⇒ Array<Mindee::V1::Parsing::Standard::StringField> (readonly)
The given name(s) of the passport holder.
30 31 32 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 30 def given_names @given_names end |
#id_number ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The passport's identification number.
33 34 35 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 33 def id_number @id_number end |
#issuance_date ⇒ Mindee::V1::Parsing::Standard::DateField (readonly)
The date the passport was issued.
36 37 38 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 36 def issuance_date @issuance_date end |
#mrz1 ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
Machine Readable Zone, first line
39 40 41 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 39 def mrz1 @mrz1 end |
#mrz2 ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
Machine Readable Zone, second line
42 43 44 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 42 def mrz2 @mrz2 end |
#surname ⇒ Mindee::V1::Parsing::Standard::StringField (readonly)
The surname of the passport holder.
45 46 47 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 45 def surname @surname end |
Instance Method Details
#to_s ⇒ String
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/mindee/v1/product/passport/passport_v1_document.rb', line 92 def to_s given_names = @given_names.join("\n #{' ' * 15}") out_str = String.new out_str << "\n:Country Code: #{@country}".rstrip out_str << "\n:ID 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:Gender: #{@gender}".rstrip out_str << "\n:Date of Issue: #{@issuance_date}".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[1..].to_s end |