Class: ContactCsv::LookupTables::LookupTable
- Inherits:
-
Object
- Object
- ContactCsv::LookupTables::LookupTable
- 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
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#legend ⇒ Object
Returns the value of attribute legend.
Instance Method Summary collapse
-
#initialize(headers, legend) ⇒ LookupTable
constructor
Initializes a LookupTable taking an Array of headers and a Hash that maps the column headers to the Contact object attributes.
-
#lookup(column) ⇒ Object
Returns the corresponding Contact attribute mapped to the specific Outlook CSV column name.
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
#headers ⇒ Object
Returns the value of attribute headers.
10 11 12 |
# File 'lib/contact_csv/lookup_tables/lookup_table.rb', line 10 def headers @headers end |
#legend ⇒ Object
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 |