Class: KindleManager::HighlightsParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/kindle_manager/parsers/highlights_parser.rb

Defined Under Namespace

Classes: BookWithNote

Instance Attribute Summary

Attributes inherited from BaseParser

#fetched_at

Instance Method Summary collapse

Methods inherited from BaseParser

#body, #doc, #initialize

Constructor Details

This class inherits a constructor from KindleManager::BaseParser

Instance Method Details

#parseObject



83
84
85
86
87
88
89
90
# File 'lib/kindle_manager/parsers/highlights_parser.rb', line 83

def parse
  @_parsed ||= begin
    result = doc.css('.kp-notebook-annotation-container').map{|e| BookWithNote.new(e, fetched_at: fetched_at) }
    puts "[DEBUG] This page(#{@filepath}) has many books. asin -> #{result.map(&:asin).join(',')}" if result.size >= 2
    puts "[DEBUG] Incomplete page(#{@filepath}). asin:#{result.first.asin} #{result.first.title} (#{result.first.count_summary['text'].inspect})" if result.any?(&:invalid?)
    result
  end
end