Sha256: 6bc9acf93e22b1088c681c18599eb528932c6c8d5f5d28b9cadc6576e2122d5c

Contents?: true

Size: 979 Bytes

Versions: 22

Compression:

Stored size: 979 Bytes

Contents

#
# Provides a base template for interface and behavior of contact importers

module Blackbook::Importer
  class Base
    attr_accessor :options

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

    def =~( options ); end # stub

    ##
    # 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.

    def fetch_contacts!; end # stub

    ##
    # 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).

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

    ##
    # Name of the importer service.

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

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
blackbook-1.0.3 lib/blackbook/importer/base.rb
blackbook-1.0.4 lib/blackbook/importer/base.rb