diff options
| author | mo k <m@mokhan.ca> | 2011-11-12 09:03:58 -0700 |
|---|---|---|
| committer | mo k <m@mokhan.ca> | 2011-11-12 09:03:58 -0700 |
| commit | d4be9fb0a52e4620175989b8f1e7024a3ec27190 (patch) | |
| tree | f2fe01ef86594223bc5cc019838961dc8991d61e /lib | |
| parent | c5afa2772b9e98cd91f46a2b4049a3e7deec0525 (diff) | |
add author, publisher and publishing year to book.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/book.rb | 5 | ||||
| -rw-r--r-- | lib/library.rb | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/book.rb b/lib/book.rb index 56f9c5a..a883e49 100644 --- a/lib/book.rb +++ b/lib/book.rb @@ -1,8 +1,11 @@ class Book attr_reader :title - def initialize(title) + def initialize(title, author, publisher, year_published) @title=title end + def is_titled?(title) + @title == title + end def ==(other) other.kind_of?( Book ) && @title == other.title end diff --git a/lib/library.rb b/lib/library.rb index 494d46f..4f1321a 100644 --- a/lib/library.rb +++ b/lib/library.rb @@ -6,6 +6,6 @@ class Library @books << book end def contains(title) - @books.find { |book| book.title == title } != nil + @books.find { |book| book.is_titled?(title) } != nil end end |
