Sha256: f7afcef11b166efd3241d46acd902318045a317d889f4816fe765684a42b540a

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require 'contacts/version'

require 'yaml' # required to parse yaml config file

module Contacts
  
  Identifier = 'Ruby Contacts v' + VERSION::STRING
  
  # An object that represents a single contact
  class Contact
    attr_reader   :organizations, :firstname, :lastname
    attr_accessor :name, :username, :service_id, :note, :emails, :ims,:phones, :addresses
    
    def initialize(email, name = nil, username = nil, firstname = nil, lastname = nil)
      @emails = []
      @emails << email if email
      @ims = []
      @phones = []
      @addresses = []
      @organizations = []
      @name = name
      @username = username
      @firstname = firstname
      @lastname = lastname
    end
    
    def email
      @emails.first
    end
    
    def inspect
      %!#<Contacts::Contact "#{name}"#{email ? " (#{email})" : ''}>!
    end
  end

  def self.verbose=(verbose)
    @verbose = verbose
  end
  
  def self.verbose?
    @verbose || 'irb' == $0
  end
  
  class Error < StandardError
  end
  
  class TooManyRedirects < Error
    attr_reader :response, :location
    
    MAX_REDIRECTS = 2
    
    def initialize(response)
      @response = response
      @location = @response['Location']
      super "exceeded maximum of #{MAX_REDIRECTS} redirects (Location: #{location})"
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aurelian-contacts-0.3.1 lib/contacts.rb
aurelian-contacts-0.3.2 lib/contacts.rb
aurelian-contacts-0.3.3 lib/contacts.rb