Sha256: 369c244809c2d695261683b2181b962c836e9dc7e97bb9731103ae6abea14d9c

Contents?: true

Size: 558 Bytes

Versions: 2

Compression:

Stored size: 558 Bytes

Contents

module KindleHighlights
  class Highlight
    attr_accessor :asin, :text, :location

    def self.from_html_elements(book:, html_elements:)
      new(
        asin: book.asin,
        text: html_elements.children.search("div.kp-notebook-highlight").first.text.squish,
        location: html_elements.children.search("input#kp-annotation-location").first.attributes["value"].value,
      )
    end

    def initialize(asin:, text:, location:)
      @asin = asin
      @text = text
      @location = location
    end

    def to_s
      text
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kindle-highlights-2.0.1 lib/kindle_highlights/highlight.rb
kindle-highlights-2.0.0 lib/kindle_highlights/highlight.rb