The Mailbox Class

Exercise 11.1

In a new file mailbox-1.rb Write a class that has a name and emails attribute. Make it so that the these attributes can be populated through the initialize method (name being a string, and emails being an array of Email instances).

The following code

class Email
  # your class from the last exercise

class Mailbox
  # fill in this class body

emails = ["Homework this week", { :date => "2014-12-01", :from => "Ferdous" }),"Keep on coding! :)", { :date => "2014-12-01", :from => "Dajana" }),"Re: Homework this week", { :date => "2014-12-02", :from => "Ariane" })
mailbox ="Ruby Study Group", emails)

mailbox.emails.each do |email|
  puts "Date:    #{}"
  puts "From:    #{email.from}"
  puts "Subject: #{email.subject}"

should then output the following:

Date:    2014-12-01
From:    Ferdous
Subject: Homework this week

Date:    2014-12-01
From:    Dajana
Subject: Keep on coding! :)

Date:    2014-12-02
From:    Arianne
Subject: Re: Homework this week

Show solution