Class: Tact::Card
- Inherits:
-
Object
- Object
- Tact::Card
- Defined in:
- lib/tact/card.rb
Instance Attribute Summary collapse
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
Instance Method Summary collapse
-
#initialize(contact, index = "*") ⇒ Card
constructor
A new instance of Card.
- #to_s ⇒ Object
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
#contact ⇒ Object (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_s ⇒ Object
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 |