Sha256: 74074a00443edcb575c8e27c711573fd6397c85f6cca85ce4e95975ee3c7da09

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 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.2 lib/nokaya/flickr_album.rb