Class: NgpodScraper::Client
- Inherits:
-
Object
- Object
- NgpodScraper::Client
- Defined in:
- lib/ngpod_scraper/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #get_photo ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #log(message) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/ngpod_scraper/client.rb', line 5 def initialize(config) @config = symbolize_keys(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/ngpod_scraper/client.rb', line 3 def config @config end |
Instance Method Details
#get_photo ⇒ Object
9 10 11 |
# File 'lib/ngpod_scraper/client.rb', line 9 def get_photo PhotoPage.new(config[:url], config).photo end |
#log(message) ⇒ Object
13 14 15 16 17 |
# File 'lib/ngpod_scraper/client.rb', line 13 def log() if config[:show_logs] puts end end |
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ngpod_scraper/client.rb', line 19 def run photo = get_photo if photo.exists? log "Wasn't able to download the photo of the day. Maybe the photo has already been downloaded." else photo.save photo.save_wallpaper log "Downloaded #{photo.path}" end photo end |