Class: KindleManager::BooksParser::BookRow
- Inherits:
-
Object
- Object
- KindleManager::BooksParser::BookRow
- Includes:
- Parsers::Common
- Defined in:
- lib/kindle_manager/parsers/books_parser.rb
Instance Method Summary collapse
- #asin ⇒ Object
- #author ⇒ Object
- #collection_count ⇒ Object
- #date ⇒ Object
-
#initialize(node, options = {}) ⇒ BookRow
constructor
A new instance of BookRow.
- #inspect ⇒ Object
- #tag ⇒ Object
- #title ⇒ Object
- #to_hash ⇒ Object
Methods included from Parsers::Common
Constructor Details
#initialize(node, options = {}) ⇒ BookRow
Returns a new instance of BookRow.
7 8 9 10 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 7 def initialize(node, = {}) @node = node @fetched_at = [:fetched_at] end |
Instance Method Details
#asin ⇒ Object
16 17 18 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 16 def asin @_asin ||= @node['name'].gsub(/\AcontentTabList_/, '') end |
#author ⇒ Object
28 29 30 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 28 def @_author ||= @node.css("div[id^='author']").text end |
#collection_count ⇒ Object
36 37 38 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 36 def collection_count @_collection_count ||= @node.css(".collectionsCount .myx-collection-count").first.text.strip.to_i end |
#date ⇒ Object
32 33 34 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 32 def date @_date ||= parse_date(@node.css("div[id^='date']").text) end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 12 def inspect "#<#{self.class.name}:#{self.object_id} #{self.to_hash}>" end |
#tag ⇒ Object
24 25 26 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 24 def tag @_tag ||= @node.css("div[id^='listViewTitleTag']").css('.myx-text-bold').first.text.strip end |
#title ⇒ Object
20 21 22 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 20 def title @_title ||= @node.css("div[id^='title']").text end |
#to_hash ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 40 def to_hash hash = {} %w[asin title tag author date collection_count].each do |f| hash[f] = send(f) end hash end |