class OcrChallenge::IContactInfo
Attributes
email_addresses[R]
names[R]
phone_numbers[R]
Public Class Methods
new(parser, list_of_names_dir='names')
click to toggle source
# File lib/ocr_challenge/i_contact_info.rb, line 5 def initialize(parser, list_of_names_dir='names') @parser = parser @names = @parser.parse_names(list_of_names_dir) @email_addresses = @parser.parse_email_addresses @phone_numbers = @parser.parse_phone_numbers end
Public Instance Methods
get_email_address()
click to toggle source
NOTE: the programming challenge does not account for multiple email addresses, so I take the first one
# File lib/ocr_challenge/i_contact_info.rb, line 21 def get_email_address "Email: #{email_addresses.first}" end
get_name()
click to toggle source
NOTE: perhaps unlikely, but a business card may have more than one name. For example, maybe there were multiple points of contact for a given company card. Since the challenge did not specify, I take the first one.
# File lib/ocr_challenge/i_contact_info.rb, line 15 def get_name "Name: #{names.first}" end
get_phone_number()
click to toggle source
NOTE: the programming challenge does not take into account that a contact can have multiple phone numbers, so I take the firs one
# File lib/ocr_challenge/i_contact_info.rb, line 27 def get_phone_number "Phone: #{phone_numbers.first}" end
to_s()
click to toggle source
# File lib/ocr_challenge/i_contact_info.rb, line 31 def to_s contact_as_string = "" {Name: names, Email: email_addresses, "Phone Number" => phone_numbers}.each_pair do |label, values| values.each do |value| contact_as_string << "#{label}: #{value}\n" end end contact_as_string end