class Fonbok::Phonebook

Attributes

contacts[R]
name[R]

Public Class Methods

new(name:, contacts: [], formatter: Formatters::SimplePhonebookFormatter.new) click to toggle source
# File lib/fonbok/phonebook.rb, line 8
def initialize(name:, contacts: [], formatter: Formatters::SimplePhonebookFormatter.new)
  @name = String(name)
  @contacts = Array(contacts)
  @formatter = formatter
end

Public Instance Methods

add_contact(contact) click to toggle source
# File lib/fonbok/phonebook.rb, line 14
def add_contact(contact)
  @contacts << contact
  self
end
inspect() click to toggle source
# File lib/fonbok/phonebook.rb, line 23
def inspect
  "<Fonbok::Phonebook name: #{name}>"
end
to_s() click to toggle source
# File lib/fonbok/phonebook.rb, line 19
def to_s
  @formatter.format(self)
end