Sha256: db13cd2e604099f5b13a80ca1f2257ab90f77e0a24f57e18e25d70594f335be3
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
# coding: utf-8 module Klipbook Book = Struct.new(:asin, :author, :title, :last_update, :clippings) do def title_and_author author_txt = author ? " by #{author}" : '' "#{title}#{author_txt}" end def sorted_clippings clippings.sort_by(&:location) end def get_binding binding end def location_html(location) if asin "<a href=\"kindle://book?action=open&asin=#{asin}&location=#{location}\">loc #{location}</a>" else "loc #{location}" end end def location_markdown(location) if asin "[∞](kindle://book?action=open&asin=#{asin}&location=#{location})" else "" end end def self.from_hash(hash) self.new.tap do |b| b.asin = hash['asin'] b.author = hash['author'] b.title = hash['title'] b.last_update = hash['last_update'] b.clippings = hash['clippings'].map { |clip| Klipbook::Clipping.from_hash(clip) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
klipbook-4.0.0 | lib/klipbook/sources/book.rb |
klipbook-3.0.0 | lib/klipbook/sources/book.rb |