Class: K2e::Kindle
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #books_highlights ⇒ Object
-
#initialize ⇒ Kindle
constructor
A new instance of Kindle.
Methods included from DateSupporter
#last_sync_date, #update_last_sync_date
Constructor Details
#initialize ⇒ Kindle
Returns a new instance of Kindle.
10 11 12 |
# File 'lib/k2e/kindle.rb', line 10 def initialize @parser = KindleClippings::Parser.new end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
8 9 10 |
# File 'lib/k2e/kindle.rb', line 8 def parser @parser end |
Instance Method Details
#books_highlights ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/k2e/kindle.rb', line 14 def books_highlights clippings = parser.parse_file(clippings_file_path) @result = {} highlights = clippings.highlights.delete_if{|highlight| highlight.added_on < last_sync_date} highlights.group_by(&:book_title).each do |book_title, book_highlights| next if book_highlights.empty? note_content = "" book_highlights.each do |highlight| str_date = Time.parse highlight.added_on.to_s note_content += <<-CONTENT <div>A highlight is created on #{str_date}, starting at location #{highlight.location} </div> <blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"> <div> <i style="background-color:rgb(255, 250, 165);-evernote-highlight:true;"> #{highlight.content} </i> </div> </blockquote> <i><br/></i> CONTENT end @result[book_title] = note_content end @result end |