Sha256: f5d99923b249037e0950b94d8e234814290adba43509dcc4999daa1265dd0204

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
module Nokaya
  class Getter
    def initialize *args
      @args = OpenStruct.new options: args[0], type: args[1], url: args[2][0]
    end
    def args
      @args.inspect
    end
    def options
      @args.options
    end
    def type
      @args.type
    end
    def url
      @args.url
    end
    def get_image img_link
      begin
        open(img_link).read
      rescue
        abort Status.no_can_do
      end
    end
    def get_basic page
      page.xpath("//meta[@property='og:image']/@content").first
    end
    def get_favd page
      page.css('#largeImage')[0]['src']
    end
    def get_imgur_album page
      refs = page.css('#imagelist .posts .post a')
      links = []
      refs.each {|l| links << "http:#{l['href']}"}
      links
    end
    def get_flickr_album page
      refs = page.css('.pc_img')
      links = []
      refs.each {|l| links << l['data-defer-src']}
      links
    end
    def parse_page
      Nokogiri::HTML get_page_content
    end
    private
    def get_page_content
      open @args.url
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.0.5 lib/nokaya/getter.rb