Class: Graybook::Importer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/graybook/importer/base.rb

Direct Known Subclasses

PageScraper

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/graybook/importer/base.rb', line 6

def options
  @options
end

Instance Method Details

#=~(options) ⇒ Object

Should return true or false/nil depending on whether the options given can be handled by this importer



12
# File 'lib/graybook/importer/base.rb', line 12

def =~( options ); end

#fetch_contacts!Object

Does the work of extracting contacts. Returns an Array of Arrays containing the name and email as the first and second elements. Of course, you can override this behavior to meet the needs of a particular service.



20
# File 'lib/graybook/importer/base.rb', line 20

def fetch_contacts!; end

#import(options = {}) ⇒ Object

Imports the contacts using the given options. Returns an array of hashes in the internal format (a hash with at least :name and :email values).



27
28
29
30
# File 'lib/graybook/importer/base.rb', line 27

def import(options = {}) 
  self.options = options
  fetch_contacts!
end

#service_nameObject

Name of the importer service.



35
36
37
# File 'lib/graybook/importer/base.rb', line 35

def service_name
  self.class.name.split("::").last
end