Class: ContactCsv::ContactManager
- Inherits:
-
Object
- Object
- ContactCsv::ContactManager
- Includes:
- ContactCsv, LookupTables
- Defined in:
- lib/contact_csv/contact_manager.rb
Overview
ContctManager
The ContactManager handles finding the appropriate lookup table and creating the array of Contact objects
Defined Under Namespace
Classes: LookupTableNotFoundError
Instance Attribute Summary collapse
-
#contacts ⇒ Object
Returns the value of attribute contacts.
-
#lookup_tables ⇒ Object
Returns the value of attribute lookup_tables.
Instance Method Summary collapse
-
#initialize(lookup_tables = []) ⇒ ContactManager
constructor
Initializes a ContactManager, accepts an Array of LookupTables.
-
#parse(csv_string) ⇒ Object
Reads a CSV string and creates a contact list.
-
#read(file_path) ⇒ Object
Reads a CSV file and creates a contact list.
Constructor Details
#initialize(lookup_tables = []) ⇒ ContactManager
Initializes a ContactManager, accepts an Array of LookupTables
13 14 15 16 |
# File 'lib/contact_csv/contact_manager.rb', line 13 def initialize(lookup_tables=[]) @lookup_tables = lookup_tables + [OutlookCsv.lookup_table] @contacts = [] end |
Instance Attribute Details
#contacts ⇒ Object
Returns the value of attribute contacts.
10 11 12 |
# File 'lib/contact_csv/contact_manager.rb', line 10 def contacts @contacts end |
#lookup_tables ⇒ Object
Returns the value of attribute lookup_tables.
10 11 12 |
# File 'lib/contact_csv/contact_manager.rb', line 10 def lookup_tables @lookup_tables end |
Instance Method Details
#parse(csv_string) ⇒ Object
Reads a CSV string and creates a contact list
25 26 27 28 |
# File 'lib/contact_csv/contact_manager.rb', line 25 def parse(csv_string) csv = FasterCSV.parse(csv_string, :headers => true) create_contacts(csv) end |
#read(file_path) ⇒ Object
Reads a CSV file and creates a contact list
19 20 21 22 |
# File 'lib/contact_csv/contact_manager.rb', line 19 def read(file_path) csv = FasterCSV.read(file_path, :headers => true) create_contacts(csv) end |