Class: Nytimesbooks::Book

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#bookdescriptionObject

Returns the value of attribute bookdescription.



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

def bookdescription
  @bookdescription
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.new_book(doc) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/nytimesbooks/books.rb', line 5

def self.new_book(doc)
  new_array = []
  doc.css("div.book-body").each do |book|
    new_book = self.new
    new_book.name = book.css("css-5pe77f").text
    new_book.author = book.css("css-hjukut").text
    new_book.bookdescription = book.css("css-14lubdp").text
    new_array << new_book
  end
  new_array
end