Class: BookDeals::Category

Inherits:
Object
  • Object
show all
Defined in:
lib/book_deals/category.rb

Overview

category is a collection of books

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, url) ⇒ Category

Returns a new instance of Category.



12
13
14
15
16
# File 'lib/book_deals/category.rb', line 12

def initialize(name, url)
  self.name = name
  self.url = url
  self.books = []
end

Instance Attribute Details

#booksObject

Returns the value of attribute books.



5
6
7
# File 'lib/book_deals/category.rb', line 5

def books
  @books
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/book_deals/category.rb', line 5

def name
  @name
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/book_deals/category.rb', line 5

def url
  @url
end

Instance Method Details

#add_book(book) ⇒ Object



7
8
9
10
# File 'lib/book_deals/category.rb', line 7

def add_book(book)
  self.books << book
  book.categories << self
end