Class: Bestsellers::Books

Inherits:
Object
  • Object
show all
Defined in:
lib/bestsellers/books.rb

Constant Summary collapse

@@books =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, author, price, url) ⇒ Books

Returns a new instance of Books.



5
6
7
8
9
10
11
# File 'lib/bestsellers/books.rb', line 5

def initialize(title, author,price, url)
    @title = title
    @author = author
    @price = price
    @url = url
    @@books << self
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



2
3
4
# File 'lib/bestsellers/books.rb', line 2

def author
  @author
end

#priceObject

Returns the value of attribute price.



2
3
4
# File 'lib/bestsellers/books.rb', line 2

def price
  @price
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/bestsellers/books.rb', line 2

def title
  @title
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/bestsellers/books.rb', line 2

def url
  @url
end

Class Method Details

.allObject



13
14
15
# File 'lib/bestsellers/books.rb', line 13

def self.all
    @@books
end