Class: Picture
- Inherits:
-
Object
- Object
- Picture
- Defined in:
- lib/picture.rb
Instance Method Summary collapse
-
#delete_duplicate_pics ⇒ Object
Deletes duplicate pictures.
-
#initialize(html) ⇒ Picture
constructor
A new instance of Picture.
-
#pic_path ⇒ Object
Download picture.
-
#picture ⇒ Object
Get path to the picture url.
Constructor Details
#initialize(html) ⇒ Picture
Returns a new instance of Picture.
2 3 4 |
# File 'lib/picture.rb', line 2 def initialize(html) @html = html end |
Instance Method Details
#delete_duplicate_pics ⇒ Object
Deletes duplicate pictures
28 29 30 31 32 33 |
# File 'lib/picture.rb', line 28 def delete_duplicate_pics pics = Dir["pictures/*.jpg.*"] pics.each do |p| File.delete(p) end end |
#pic_path ⇒ Object
Download picture
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/picture.rb', line 14 def pic_path if picture # Get path dir = "pictures/" full_path = dir+picture.split("/").last.chomp.strip # Get file `wget -P #{dir} #{picture}` if !File.file?(full_path) delete_duplicate_pics return full_path end end |
#picture ⇒ Object
Get path to the picture url
7 8 9 10 11 |
# File 'lib/picture.rb', line 7 def picture pic = @html.css('.profile-picture').css('img').first pic_url = pic['src'] ? pic['src'] : pic['data-delayed-url'] return pic_url end |