Sha256: 52572ec3e878bd5ac6664bba4804c7ff90a89c99cf5f3c7724ca1d034ce35b9c

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

# encoding: utf-8
module Nokaya

  class ImgurAlbum < Basic

    attr_reader :author

    def initialize args, options = {}
      super(args, options)
      @type = :imgur
      parsed = self.parse(args[0])
      @author = author(parsed)
      @image_url = album(parsed)
      @path = "#{@path}/imgur-#{@author}-#{@workers.timed}"
      @file_name = name()
    end

    private

    def album page
      refs = page.css('#imagelist .posts .post a')
      refs.map {|l| "http:#{l['href']}"}
    end

    def name
      @image_url.map do |url|
        "#{@type.to_s}-#{@author}-#{File.basename(url)}"
      end
    end

    def author page
      res = page.css('.description')[0].children[1].children.text
      @workers.sanitize(res)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.1.2 lib/nokaya/imgur_album.rb