Class: Mindee::Product::US::UsMail::UsMailV2RecipientAddress

Inherits:
Mindee::Parsing::Standard::FeatureField show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb

Overview

The addresses of the recipients.

Instance Attribute Summary collapse

Attributes inherited from Mindee::Parsing::Standard::AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from Mindee::Parsing::Standard::FeatureField

#format_for_display

Methods inherited from Mindee::Parsing::Standard::AbstractField

array_confidence, array_sum, float_to_string

Constructor Details

#initialize(prediction, page_id) ⇒ UsMailV2RecipientAddress

Returns a new instance of UsMailV2RecipientAddress.

Parameters:

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


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 36

def initialize(prediction, page_id)
  super(prediction, page_id)
  @city = prediction['city']
  @complete = prediction['complete']
  @is_address_change = prediction['is_address_change']
  @postal_code = prediction['postal_code']
  @private_mailbox_number = prediction['private_mailbox_number']
  @state = prediction['state']
  @street = prediction['street']
  @page_id = page_id
end

Instance Attribute Details

#cityString (readonly)

The city of the recipient's address.

Returns:

  • (String)


14
15
16
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 14

def city
  @city
end

#completeString (readonly)

The complete address of the recipient.

Returns:

  • (String)


17
18
19
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 17

def complete
  @complete
end

#is_address_changeBoolean (readonly)

Indicates if the recipient's address is a change of address.

Returns:

  • (Boolean)


20
21
22
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 20

def is_address_change
  @is_address_change
end

#postal_codeString (readonly)

The postal code of the recipient's address.

Returns:

  • (String)


23
24
25
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 23

def postal_code
  @postal_code
end

#private_mailbox_numberString (readonly)

The private mailbox number of the recipient's address.

Returns:

  • (String)


26
27
28
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 26

def private_mailbox_number
  @private_mailbox_number
end

#stateString (readonly)

Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.

Returns:

  • (String)


29
30
31
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 29

def state
  @state
end

#streetString (readonly)

The street of the recipient's address.

Returns:

  • (String)


32
33
34
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 32

def street
  @street
end

Instance Method Details

#printable_valuesHash

Returns:

  • (Hash)


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 49

def printable_values
  printable = {}
  printable[:city] = format_for_display(@city)
  printable[:complete] = format_for_display(@complete)
  printable[:is_address_change] = format_for_display(@is_address_change)
  printable[:postal_code] = format_for_display(@postal_code)
  printable[:private_mailbox_number] = format_for_display(@private_mailbox_number)
  printable[:state] = format_for_display(@state)
  printable[:street] = format_for_display(@street)
  printable
end

#table_printable_valuesHash

Returns:

  • (Hash)


62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 62

def table_printable_values
  printable = {}
  printable[:city] = format_for_display(@city, 15)
  printable[:complete] = format_for_display(@complete, 35)
  printable[:is_address_change] = format_for_display(@is_address_change, nil)
  printable[:postal_code] = format_for_display(@postal_code, nil)
  printable[:private_mailbox_number] = format_for_display(@private_mailbox_number, nil)
  printable[:state] = format_for_display(@state, nil)
  printable[:street] = format_for_display(@street, 25)
  printable
end

#to_sString

Returns:

  • (String)


89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 89

def to_s
  printable = printable_values
  out_str = String.new
  out_str << "\n  :City: #{printable[:city]}"
  out_str << "\n  :Complete Address: #{printable[:complete]}"
  out_str << "\n  :Is Address Change: #{printable[:is_address_change]}"
  out_str << "\n  :Postal Code: #{printable[:postal_code]}"
  out_str << "\n  :Private Mailbox Number: #{printable[:private_mailbox_number]}"
  out_str << "\n  :State: #{printable[:state]}"
  out_str << "\n  :Street: #{printable[:street]}"
  out_str
end

#to_table_lineString

Returns:

  • (String)


75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb', line 75

def to_table_line
  printable = table_printable_values
  out_str = String.new
  out_str << format('| %- 16s', printable[:city])
  out_str << format('| %- 36s', printable[:complete])
  out_str << format('| %- 18s', printable[:is_address_change])
  out_str << format('| %- 12s', printable[:postal_code])
  out_str << format('| %- 23s', printable[:private_mailbox_number])
  out_str << format('| %- 6s', printable[:state])
  out_str << format('| %- 26s', printable[:street])
  out_str << '|'
end