Class: BookClubPicks::Book

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

Constant Summary collapse

DOC =
Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, author = nil, published = nil, clubs = nil, summary = nil) ⇒ Book

Returns a new instance of Book.



7
8
9
10
11
12
13
# File 'lib/book_club_picks/books.rb', line 7

def initialize(name = nil, author = nil, published = nil, clubs = nil, summary = nil)
  @name = name
  @author = author
  @published = published
  @clubs = clubs
  @summary = summary
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



3
4
5
# File 'lib/book_club_picks/books.rb', line 3

def author
  @author
end

#clubsObject

Returns the value of attribute clubs.



3
4
5
# File 'lib/book_club_picks/books.rb', line 3

def clubs
  @clubs
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/book_club_picks/books.rb', line 3

def name
  @name
end

#publishedObject

Returns the value of attribute published.



3
4
5
# File 'lib/book_club_picks/books.rb', line 3

def published
  @published
end

#summaryObject

Returns the value of attribute summary.



3
4
5
# File 'lib/book_club_picks/books.rb', line 3

def summary
  @summary
end

Class Method Details

.scrape_details(num) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/book_club_picks/books.rb', line 15

def self.scrape_details(num)
  DOC
  
  individual_details = self.new
  individual_details.name = DOC.search("h2")[num].text.strip
  individual_details.published = DOC.search("div.midd .omatter")[num].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
  individual_details.clubs = DOC.css(".recomnd")[num].text.strip
  individual_details.summary = DOC.css(".midd .statement")[num].text.strip.gsub('â', "\'").gsub('Â', " ")

  individual_details
end