Class: Klipbook::Book
Instance Attribute Summary collapse
-
#asin ⇒ Object
Returns the value of attribute asin.
-
#author ⇒ Object
Returns the value of attribute author.
-
#clippings ⇒ Object
Returns the value of attribute clippings.
-
#last_update ⇒ Object
Returns the value of attribute last_update.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #get_binding ⇒ Object
- #location_html(location) ⇒ Object
- #location_markdown(location) ⇒ Object
- #sorted_clippings ⇒ Object
- #title_and_author ⇒ Object
Methods inherited from Struct
Instance Attribute Details
#asin ⇒ Object
Returns the value of attribute asin
3 4 5 |
# File 'lib/klipbook/sources/book.rb', line 3 def asin @asin end |
#author ⇒ Object
Returns the value of attribute author
3 4 5 |
# File 'lib/klipbook/sources/book.rb', line 3 def @author end |
#clippings ⇒ Object
Returns the value of attribute clippings
3 4 5 |
# File 'lib/klipbook/sources/book.rb', line 3 def clippings @clippings end |
#last_update ⇒ Object
Returns the value of attribute last_update
3 4 5 |
# File 'lib/klipbook/sources/book.rb', line 3 def last_update @last_update end |
#title ⇒ Object
Returns the value of attribute title
3 4 5 |
# File 'lib/klipbook/sources/book.rb', line 3 def title @title end |
Class Method Details
.from_hash(hash) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/klipbook/sources/book.rb', line 33 def self.from_hash(hash) self.new.tap do |b| b.asin = hash['asin'] b. = 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 |
Instance Method Details
#get_binding ⇒ Object
13 14 15 |
# File 'lib/klipbook/sources/book.rb', line 13 def get_binding binding end |
#location_html(location) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/klipbook/sources/book.rb', line 17 def location_html(location) if asin "<a href=\"kindle://book?action=open&asin=#{asin}&location=#{location}\">loc #{location}</a>" else "loc #{location}" end end |
#location_markdown(location) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/klipbook/sources/book.rb', line 25 def location_markdown(location) if asin "[∞](kindle://book?action=open&asin=#{asin}&location=#{location})" else "" end end |
#sorted_clippings ⇒ Object
9 10 11 |
# File 'lib/klipbook/sources/book.rb', line 9 def sorted_clippings clippings.sort_by(&:location) end |
#title_and_author ⇒ Object
4 5 6 7 |
# File 'lib/klipbook/sources/book.rb', line 4 def = ? " by #{}" : '' "#{title}#{}" end |