Class: Tact::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/tact/card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contact, index = "*") ⇒ Card

Returns a new instance of Card.



4
5
6
7
# File 'lib/tact/card.rb', line 4

def initialize(contact, index="*")
  @contact = contact
  @index = index
end

Instance Attribute Details

#contactObject (readonly)

Returns the value of attribute contact.



3
4
5
# File 'lib/tact/card.rb', line 3

def contact
  @contact
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
# File 'lib/tact/card.rb', line 9

def to_s
  string = "=" * 40 + "\n"
  string += "[#{@index}]".red + " #{@contact.to_s}"
  contact.phone_numbers.each_with_index {|number, i| string += "\s\s" + "[#{i + 1}] " + number.to_s + "\n"}
  contact.emails.each_with_index {|address, i| string += "\s\s\s\s" + "[#{i + 1}] " + address.to_s + "\n"}
  string += "=" * 40 + "\n"
end