Class: BookscanClient
- Inherits:
-
Object
- Object
- BookscanClient
- Defined in:
- lib/bookscan_client.rb,
lib/bookscan_client/version.rb,
lib/bookscan_client/model/book.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #books ⇒ Object
- #cookies ⇒ Object
-
#initialize(logger: Logger.new(STDOUT), sleep: 0.5) ⇒ BookscanClient
constructor
A new instance of BookscanClient.
- #login(email, password) ⇒ Object
- #login? ⇒ Boolean
Constructor Details
#initialize(logger: Logger.new(STDOUT), sleep: 0.5) ⇒ BookscanClient
Returns a new instance of BookscanClient.
17 18 19 20 21 |
# File 'lib/bookscan_client.rb', line 17 def initialize(logger: Logger.new(STDOUT), sleep: 0.5) @mechanize = Mechanize.new @logger = logger @sleep = sleep end |
Instance Method Details
#books ⇒ Object
32 33 34 35 |
# File 'lib/bookscan_client.rb', line 32 def books page = fetch(URL::MYPAGE) BookscanClient::Model::Book.parse_books(page) end |
#cookies ⇒ Object
37 38 39 |
# File 'lib/bookscan_client.rb', line 37 def @mechanize. end |
#login(email, password) ⇒ Object
23 24 25 |
# File 'lib/bookscan_client.rb', line 23 def login(email, password) @mechanize.post(URL::LOGIN, "email" => email, "password" => password) end |
#login? ⇒ Boolean
27 28 29 30 |
# File 'lib/bookscan_client.rb', line 27 def login? names = .map(&:name) names.include?("email") && names.include?("password") end |