Class: Klipbook::Sources::Source
- Inherits:
-
Object
- Object
- Klipbook::Sources::Source
- Defined in:
- lib/klipbook/sources/source.rb
Class Method Summary collapse
- .build(options) ⇒ Object
- .file_source(file, max_books) ⇒ Object
- .site_source(credentials, max_books) ⇒ Object
Class Method Details
.build(options) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/klipbook/sources/source.rb', line 4 def self.build() if .from_file file_source(.from_file, .count) elsif .from_site site_source(.from_site, .count) else raise "Unknown source type" end end |
.file_source(file, max_books) ⇒ Object
25 26 27 |
# File 'lib/klipbook/sources/source.rb', line 25 def self.file_source(file, max_books) Sources::KindleDevice::File.new(File.read(file), max_books) end |
.site_source(credentials, max_books) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/klipbook/sources/source.rb', line 14 def self.site_source(credentials, max_books) unless credentials =~ /(.+):(.+)/ logger.error "Error: your credentials need to be in username:password format." exit 127 end username = $1 password = $2 Sources::AmazonSite::SiteScraper.new(username, password, max_books) end |