Sha256: 06e0aecd1cbf224e7cf1752281d0dbc345fb7446cdff07887f4f432a5cc3d306

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

require 'contacts/version'

module Contacts
  
  Identifier = 'Ruby Contacts v' + VERSION::STRING
  
  # An object that represents a single contact
  class Contact
    attr_reader :name, :username, :emails
    
    def initialize(email, name = nil, username = nil)
      @emails = []
      @emails << email if email
      @name = name
      @username = username
    end
    
    def email
      @emails.first
    end
    
    def inspect
      %!#<Contacts::Contact "#{name}" (#{email})>!
    end
  end
  
  def self.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
pezra-contacts-0.1.0 lib/contacts.rb