Class: KindleNotebook::Highlight
- Inherits:
-
Object
- Object
- KindleNotebook::Highlight
- Defined in:
- lib/kindle_notebook/highlight.rb
Instance Attribute Summary collapse
-
#book_asin ⇒ Object
readonly
Returns the value of attribute book_asin.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#raw_context ⇒ Object
readonly
Returns the value of attribute raw_context.
-
#raw_text ⇒ Object
readonly
Returns the value of attribute raw_text.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #attributes ⇒ Object
- #book ⇒ Object
-
#initialize(highlight_attrs) ⇒ Highlight
constructor
A new instance of Highlight.
- #to_csv ⇒ Object
Constructor Details
#initialize(highlight_attrs) ⇒ Highlight
Returns a new instance of Highlight.
7 8 9 10 11 12 13 14 |
# File 'lib/kindle_notebook/highlight.rb', line 7 def initialize(highlight_attrs) @text = highlight_attrs[:text] @page = highlight_attrs[:page] @context = highlight_attrs[:context] @book_asin = highlight_attrs[:book_asin] @raw_text = highlight_attrs[:raw_text] @raw_context = highlight_attrs[:raw_context] end |
Instance Attribute Details
#book_asin ⇒ Object (readonly)
Returns the value of attribute book_asin.
5 6 7 |
# File 'lib/kindle_notebook/highlight.rb', line 5 def book_asin @book_asin end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/kindle_notebook/highlight.rb', line 5 def context @context end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/kindle_notebook/highlight.rb', line 5 def page @page end |
#raw_context ⇒ Object (readonly)
Returns the value of attribute raw_context.
5 6 7 |
# File 'lib/kindle_notebook/highlight.rb', line 5 def raw_context @raw_context end |
#raw_text ⇒ Object (readonly)
Returns the value of attribute raw_text.
5 6 7 |
# File 'lib/kindle_notebook/highlight.rb', line 5 def raw_text @raw_text end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/kindle_notebook/highlight.rb', line 5 def text @text end |
Instance Method Details
#attributes ⇒ Object
20 21 22 |
# File 'lib/kindle_notebook/highlight.rb', line 20 def attributes instance_variables.map { |v| v.to_s.gsub("@", "").to_sym } end |
#book ⇒ Object
16 17 18 |
# File 'lib/kindle_notebook/highlight.rb', line 16 def book @book ||= Client.books.find { |b| b.asin == book_asin } end |
#to_csv ⇒ Object
24 25 26 |
# File 'lib/kindle_notebook/highlight.rb', line 24 def to_csv CSV::Row.new(attributes, attributes.map { |a| instance_variable_get("@#{a}") }).to_s end |