Class: Mindee::Product::US::UsMail::UsMailV2Document

Inherits:
Mindee::Parsing::Common::Prediction show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/us/us_mail/us_mail_v2_document.rb

Overview

US Mail API version 2.0 document data.

Direct Known Subclasses

UsMailV2PagePrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ UsMailV2Document

Returns a new instance of UsMailV2Document.

Parameters:

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


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mindee/product/us/us_mail/us_mail_v2_document.rb', line 29

def initialize(prediction, page_id)
  super()
  @recipient_addresses = []
  prediction['recipient_addresses'].each do |item|
    @recipient_addresses.push(UsMailV2RecipientAddress.new(item, page_id))
  end
  @recipient_names = []
  prediction['recipient_names'].each do |item|
    @recipient_names.push(StringField.new(item, page_id))
  end
  @sender_address = UsMailV2SenderAddress.new(prediction['sender_address'], page_id)
  @sender_name = StringField.new(prediction['sender_name'], page_id)
end

Instance Attribute Details

#recipient_addressesArray<Mindee::Product::US::UsMail::UsMailV2RecipientAddress> (readonly)

The addresses of the recipients.



16
17
18
# File 'lib/mindee/product/us/us_mail/us_mail_v2_document.rb', line 16

def recipient_addresses
  @recipient_addresses
end

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

The names of the recipients.



19
20
21
# File 'lib/mindee/product/us/us_mail/us_mail_v2_document.rb', line 19

def recipient_names
  @recipient_names
end

#sender_addressMindee::Product::US::UsMail::UsMailV2SenderAddress (readonly)

The address of the sender.



22
23
24
# File 'lib/mindee/product/us/us_mail/us_mail_v2_document.rb', line 22

def sender_address
  @sender_address
end

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

The name of the sender.



25
26
27
# File 'lib/mindee/product/us/us_mail/us_mail_v2_document.rb', line 25

def sender_name
  @sender_name
end

Instance Method Details

#to_sString

Returns:

  • (String)


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mindee/product/us/us_mail/us_mail_v2_document.rb', line 44

def to_s
  sender_address = @sender_address.to_s
  recipient_names = @recipient_names.join("\n #{' ' * 17}")
  recipient_addresses = recipient_addresses_to_s
  out_str = String.new
  out_str << "\n:Sender Name: #{@sender_name}".rstrip
  out_str << "\n:Sender Address:"
  out_str << sender_address
  out_str << "\n:Recipient Names: #{recipient_names}".rstrip
  out_str << "\n:Recipient Addresses:"
  out_str << recipient_addresses
  out_str[1..].to_s
end