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
- #title_node ⇒ 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
21 22 23 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 21 def asin @_asin ||= title_node.attributes['id'].value.remove('content-title-') end |
#author ⇒ Object
33 34 35 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 33 def @_author ||= @node.css("div[id^='content-author-']").text end |
#collection_count ⇒ Object
41 42 43 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 41 def collection_count @_collection_count ||= @node.css('.dropdown_count').first&.text&.strip.to_i end |
#date ⇒ Object
37 38 39 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 37 def date @_date ||= parse_date(@node.css("div[id^='content-acquired-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
29 30 31 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 29 def tag @_tag ||= @node.css('.information_row.tags').first&.text&.strip end |
#title ⇒ Object
25 26 27 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 25 def title @_title ||= title_node.text end |
#title_node ⇒ Object
16 17 18 19 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 16 def title_node # Possible to use "div[id^='content-title-']" @_title_node ||= @node.css('.digital_entity_title').first end |
#to_hash ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/kindle_manager/parsers/books_parser.rb', line 45 def to_hash hash = {} %w[asin title tag author date collection_count].each do |f| hash[f] = send(f) end hash end |