Sha256: c4376c0dd2e1a4ecd1f2aadd35cec5c9dc69ba38ffcd132128b591f76d20533c

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'contacts/version'

module Contacts
  
  Identifier = 'Ruby Contacts v' + VERSION::STRING
  
  # An object that represents a single contact
  class Contact
    attr_reader :emails, :ims, :phones, :addresses, :organizations
    attr_accessor :name, :username, :service_id, :note
    
    def initialize(email, name = nil, username = nil)
      @emails = []
      @emails << email if email
      @ims = []
      @phones = []
      @addresses = []
      @organizations = []
      @name = name
      @username = username
    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

1 entries across 1 versions & 1 rubygems

Version Path
aeden-contacts-0.2.15 lib/contacts.rb