class PhotoParser

Creating photo parser class since future development is planned (adding audio parser, video parser and etc.)

Constants

ALBUM

Link to the pics

Attributes

photo_urls[R]

Public Class Methods

new() click to toggle source
# File lib/glad_valakas.rb, line 23
def initialize
  @photo_urls = []
end

Public Instance Methods

get_photos_urls() click to toggle source

This function returns array of URLs

# File lib/glad_valakas.rb, line 28
def get_photos_urls
  photo_page = HTTParty.get(ALBUM)
  @parsed_photo_page = Nokogiri::HTML(photo_page)

  @parsed_photo_page.xpath('//img').each do |data|
    @photo_urls.push data.attr('data-src_big').to_s.match(/https\S+jpg/).to_s
  end

  # Deleting all empty elements (it's needed, trust me)
  @photo_urls -= [""]
end