Sha256: c6e90528560f0756e703600366391a323c12121782046773443da53d9e5a30bb

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

# encoding: utf-8
module Nokaya

  class FlickrAlbum < Basic

    attr_reader :author

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

    private

    def title page
      @workers.sanitize(page.css('.set-title')[0].text)
    end

    def album page
      refs = page.css('.pc_img')
      refs.map {|l| l['data-defer-src']}
    end

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

    def author
      /photos\/\w+/.match(@args[0]).to_s.split('/')[1]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.1.1 lib/nokaya/flickr_album.rb