Class: ContactCsv::LookupTables::LookupTable

Inherits:
Object
  • Object
show all
Defined in:
lib/contact_csv/lookup_tables/lookup_table.rb

Overview

LookupTable

This class is so users can define their own lookup tables if it isn't supported natively. The headers is an 
Array of Strings that define the column names for the CSV file. Legend is a hash that maps the column strings 
to a Contact class attribute. Look at the Contact class for a list of available attributes.

Defined Under Namespace

Classes: InvalidInputFormatError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers, legend) ⇒ LookupTable

Initializes a LookupTable taking an Array of headers and a Hash that maps the column headers to the Contact object attributes



13
14
15
16
17
# File 'lib/contact_csv/lookup_tables/lookup_table.rb', line 13

def initialize(headers, legend)
  raise InvalidInputFormatError unless headers.is_a?(Array) && legend.is_a?(Hash)
  @headers = headers
  @legend = legend
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



10
11
12
# File 'lib/contact_csv/lookup_tables/lookup_table.rb', line 10

def headers
  @headers
end

#legendObject

Returns the value of attribute legend.



10
11
12
# File 'lib/contact_csv/lookup_tables/lookup_table.rb', line 10

def legend
  @legend
end

Instance Method Details

#lookup(column) ⇒ Object

Returns the corresponding Contact attribute mapped to the specific Outlook CSV column name



21
22
23
# File 'lib/contact_csv/lookup_tables/lookup_table.rb', line 21

def lookup(column)
  @legend[column]
end