Class: KindleManager::Client
- Inherits:
-
Object
- Object
- KindleManager::Client
- Includes:
- AmazonAuth::CommonExtension
- Defined in:
- lib/kindle_manager/client.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #fetch_kindle_highlights ⇒ Object
- #fetch_kindle_list ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #load_kindle_books ⇒ Object
- #load_kindle_highlights ⇒ Object
- #quit ⇒ Object
- #session ⇒ Object
- #set_adapter(type, options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/kindle_manager/client.rb', line 7 def initialize( = {}) @options = @client = AmazonAuth::Client.new(@options) extend(AmazonAuth::SessionExtension) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/kindle_manager/client.rb', line 5 def adapter @adapter end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/kindle_manager/client.rb', line 5 def @options end |
Instance Method Details
#fetch_kindle_highlights ⇒ Object
23 24 25 26 27 |
# File 'lib/kindle_manager/client.rb', line 23 def fetch_kindle_highlights sign_in KindleManager::HighlightsAdapter::KINDLE_HIGHLIGHT_URL set_adapter(:highlights, @options.merge(session: session)) adapter.fetch end |
#fetch_kindle_list ⇒ Object
17 18 19 20 21 |
# File 'lib/kindle_manager/client.rb', line 17 def fetch_kindle_list sign_in set_adapter(:books, @options.merge(session: session)) adapter.fetch end |
#load_kindle_books ⇒ Object
29 30 31 32 |
# File 'lib/kindle_manager/client.rb', line 29 def load_kindle_books set_adapter(:books, @options.except(:create)) adapter.load end |
#load_kindle_highlights ⇒ Object
34 35 36 37 |
# File 'lib/kindle_manager/client.rb', line 34 def load_kindle_highlights set_adapter(:highlights, @options.except(:create)) adapter.load end |
#quit ⇒ Object
39 40 41 |
# File 'lib/kindle_manager/client.rb', line 39 def quit session.driver.quit end |
#session ⇒ Object
13 14 15 |
# File 'lib/kindle_manager/client.rb', line 13 def session @_session ||= @client.session end |
#set_adapter(type, options) ⇒ Object
43 44 45 |
# File 'lib/kindle_manager/client.rb', line 43 def set_adapter(type, ) @adapter = "KindleManager::#{type.to_s.camelize}Adapter".constantize.new(.merge(sub_dir: type)) end |