class Ngphoto
Constants
- NG_PHOTO_OF_THE_DAY_URL
Attributes
title[R]
url[R]
Public Class Methods
fetch()
click to toggle source
# File lib/ngphoto.rb, line 18 def self.fetch doc = Nokogiri::HTML(open(NG_PHOTO_OF_THE_DAY_URL)) title = doc.css('title').first.text url = doc.css('.download_link a').first[:href] Ngphoto.new title, url end
new(title, url)
click to toggle source
# File lib/ngphoto.rb, line 9 def initialize(title, url) @title = Time.now.strftime('%Y-%m-%d-') + title.split('--')[0].strip.gsub(' ', '-').downcase @url = url end
Public Instance Methods
save()
click to toggle source
# File lib/ngphoto.rb, line 14 def save system "curl -o ~/Pictures/ngphoto/#{title}.jpg #{url}" end