Class: KindleHighlight::Highlight
- Inherits:
-
Object
- Object
- KindleHighlight::Highlight
- Includes:
- ASIN::Client
- Defined in:
- lib/kindle-highlights.rb
Constant Summary collapse
- @@amazon_items =
Hash.new
Instance Attribute Summary collapse
-
#annotation_id ⇒ Object
Returns the value of attribute annotation_id.
-
#asin ⇒ Object
Returns the value of attribute asin.
-
#author ⇒ Object
Returns the value of attribute author.
-
#content ⇒ Object
Returns the value of attribute content.
-
#details_url ⇒ Object
Returns the value of attribute details_url.
-
#end_location ⇒ Object
Returns the value of attribute end_location.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#note ⇒ Object
Returns the value of attribute note.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(highlight, should_lookup_book = true) ⇒ Highlight
constructor
A new instance of Highlight.
- #lookup_item ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(highlight, should_lookup_book = true) ⇒ Highlight
Returns a new instance of Highlight.
52 53 54 55 56 57 58 59 |
# File 'lib/kindle-highlights.rb', line 52 def initialize(highlight, should_lookup_book=true) self.annotation_id = highlight.xpath("form/input[@id='annotation_id']").attribute("value").value self.asin = highlight.xpath("p/span[@class='hidden asin']").text self.content = highlight.xpath("span[@class='highlight']").text rescue "" self.note = highlight.xpath("span[@class='noteContent']").text rescue "" self.end_location = highlight.xpath("span[@class='end_location']").text lookup_item if should_lookup_book end |
Instance Attribute Details
#annotation_id ⇒ Object
Returns the value of attribute annotation_id.
47 48 49 |
# File 'lib/kindle-highlights.rb', line 47 def annotation_id @annotation_id end |
#asin ⇒ Object
Returns the value of attribute asin.
47 48 49 |
# File 'lib/kindle-highlights.rb', line 47 def asin @asin end |
#author ⇒ Object
Returns the value of attribute author.
48 49 50 |
# File 'lib/kindle-highlights.rb', line 48 def @author end |
#content ⇒ Object
Returns the value of attribute content.
48 49 50 |
# File 'lib/kindle-highlights.rb', line 48 def content @content end |
#details_url ⇒ Object
Returns the value of attribute details_url.
48 49 50 |
# File 'lib/kindle-highlights.rb', line 48 def details_url @details_url end |
#end_location ⇒ Object
Returns the value of attribute end_location.
47 48 49 |
# File 'lib/kindle-highlights.rb', line 47 def end_location @end_location end |
#image_url ⇒ Object
Returns the value of attribute image_url.
48 49 50 |
# File 'lib/kindle-highlights.rb', line 48 def image_url @image_url end |
#note ⇒ Object
Returns the value of attribute note.
47 48 49 |
# File 'lib/kindle-highlights.rb', line 47 def note @note end |
#title ⇒ Object
Returns the value of attribute title.
48 49 50 |
# File 'lib/kindle-highlights.rb', line 48 def title @title end |
Instance Method Details
#lookup_item ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/kindle-highlights.rb', line 61 def lookup_item amazon_item = lookup_or_get_from_cache(self.asin) self.title = amazon_item.title self. = amazon_item.raw.ItemAttributes.Author rescue nil self.details_url = amazon_item.details_url self.image_url = amazon_item.image_url end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/kindle-highlights.rb', line 69 def to_s "<Highlight##{annotation_id}>" end |