Sha256: 38244fd00f351e8510673762dabba24e54c17a81de28dc08c8c835d0b192af9e

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 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.1 lib/nokaya/imgur_album.rb