Class: Mindee::Product::BusinessCard::BusinessCardV1Document

Inherits:
Mindee::Parsing::Common::Prediction show all
Includes:
Mindee::Parsing::Standard
Defined in:
lib/mindee/product/business_card/business_card_v1_document.rb

Overview

Business Card API version 1.0 document data.

Direct Known Subclasses

BusinessCardV1PagePrediction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ BusinessCardV1Document

Returns a new instance of BusinessCardV1Document.

Parameters:

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


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 47

def initialize(prediction, page_id)
  super()
  @address = StringField.new(prediction['address'], page_id)
  @company = StringField.new(prediction['company'], page_id)
  @email = StringField.new(prediction['email'], page_id)
  @fax_number = StringField.new(prediction['fax_number'], page_id)
  @firstname = StringField.new(prediction['firstname'], page_id)
  @job_title = StringField.new(prediction['job_title'], page_id)
  @lastname = StringField.new(prediction['lastname'], page_id)
  @mobile_number = StringField.new(prediction['mobile_number'], page_id)
  @phone_number = StringField.new(prediction['phone_number'], page_id)
  @social_media = []
  prediction['social_media'].each do |item|
    @social_media.push(StringField.new(item, page_id))
  end
  @website = StringField.new(prediction['website'], page_id)
end

Instance Attribute Details

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

The address of the person.



13
14
15
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 13

def address
  @address
end

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

The company the person works for.



16
17
18
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 16

def company
  @company
end

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

The email address of the person.



19
20
21
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 19

def email
  @email
end

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

The Fax number of the person.



22
23
24
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 22

def fax_number
  @fax_number
end

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

The given name of the person.



25
26
27
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 25

def firstname
  @firstname
end

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

The job title of the person.



28
29
30
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 28

def job_title
  @job_title
end

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

The lastname of the person.



31
32
33
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 31

def lastname
  @lastname
end

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

The mobile number of the person.



34
35
36
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 34

def mobile_number
  @mobile_number
end

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

The phone number of the person.



37
38
39
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 37

def phone_number
  @phone_number
end

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

The social media profiles of the person or company.



40
41
42
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 40

def social_media
  @social_media
end

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

The website of the person or company.



43
44
45
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 43

def website
  @website
end

Instance Method Details

#to_sString

Returns:

  • (String)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/mindee/product/business_card/business_card_v1_document.rb', line 66

def to_s
  social_media = @social_media.join("\n #{' ' * 14}")
  out_str = String.new
  out_str << "\n:Firstname: #{@firstname}".rstrip
  out_str << "\n:Lastname: #{@lastname}".rstrip
  out_str << "\n:Job Title: #{@job_title}".rstrip
  out_str << "\n:Company: #{@company}".rstrip
  out_str << "\n:Email: #{@email}".rstrip
  out_str << "\n:Phone Number: #{@phone_number}".rstrip
  out_str << "\n:Mobile Number: #{@mobile_number}".rstrip
  out_str << "\n:Fax Number: #{@fax_number}".rstrip
  out_str << "\n:Address: #{@address}".rstrip
  out_str << "\n:Website: #{@website}".rstrip
  out_str << "\n:Social Media: #{social_media}".rstrip
  out_str[1..].to_s
end