Class: BookClubPicks::Book
- Inherits:
-
Object
- Object
- BookClubPicks::Book
- Defined in:
- lib/book_club_picks/books.rb
Constant Summary collapse
- DOC =
Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#clubs ⇒ Object
Returns the value of attribute clubs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#published ⇒ Object
Returns the value of attribute published.
-
#summary ⇒ Object
Returns the value of attribute summary.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, author = nil, published = nil, clubs = nil, summary = nil) ⇒ Book
constructor
A new instance of Book.
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, = nil, published = nil, clubs = nil, summary = nil) @name = name = @published = published @clubs = clubs @summary = summary end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/book_club_picks/books.rb', line 3 def end |
#clubs ⇒ Object
Returns the value of attribute clubs.
3 4 5 |
# File 'lib/book_club_picks/books.rb', line 3 def clubs @clubs end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/book_club_picks/books.rb', line 3 def name @name end |
#published ⇒ Object
Returns the value of attribute published.
3 4 5 |
# File 'lib/book_club_picks/books.rb', line 3 def published @published end |
#summary ⇒ Object
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 |