Class: KindleNotebook::Book

Inherits:
Object
  • Object
show all
Defined in:
lib/kindle_notebook/book.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(book_attrs) ⇒ Book

Returns a new instance of Book.



8
9
10
11
12
13
14
# File 'lib/kindle_notebook/book.rb', line 8

def initialize(book_attrs)
  @author = book_attrs[:author]
  @title = book_attrs[:title]
  @asin = book_attrs[:asin]
  @highlights_count = nil
  @highlights = []
end

Instance Attribute Details

#asinObject (readonly)

Returns the value of attribute asin.



5
6
7
# File 'lib/kindle_notebook/book.rb', line 5

def asin
  @asin
end

#authorObject (readonly)

Returns the value of attribute author.



5
6
7
# File 'lib/kindle_notebook/book.rb', line 5

def author
  @author
end

#highlightsObject

Returns the value of attribute highlights.



6
7
8
# File 'lib/kindle_notebook/book.rb', line 6

def highlights
  @highlights
end

#highlights_countObject

Returns the value of attribute highlights_count.



6
7
8
# File 'lib/kindle_notebook/book.rb', line 6

def highlights_count
  @highlights_count
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/kindle_notebook/book.rb', line 5

def title
  @title
end

Instance Method Details

#fetch_highlightsObject



16
17
18
19
# File 'lib/kindle_notebook/book.rb', line 16

def fetch_highlights
  open_book unless session.current_url.include?(asin)
  Highlights.new(self).fetch
end

#to_csv_fileObject



21
22
23
24
# File 'lib/kindle_notebook/book.rb', line 21

def to_csv_file
  headers = highlights.first.attributes
  Helpers.to_csv_file(headers, highlights, "#{title} - #{author}.csv")
end