Sha256: 53a43a3b6ae64682fcf9976c7e5f57bb807a94b61b69ac509ef601c8757d8af1

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

# encoding: utf-8
module Nokaya

  class Favd < Basic

    attr_reader :author

    def initialize args, options = {}
      super(args, options)
      url = if options[:post]
              "http://pic.favd.net/#{args[0]}"
            else
              args[0]
            end
      @type = :favd
      parsed = parse(url)
      @urls = get_favd(parsed).compact
      @author = author_name(parsed)
      @filenames = name_files()
    end

    private

    def author_name page
      username = page.css('.username')
      username.empty? ? [] : username[0].text
    end

    def get_favd page
      img = page.css('#largeImage')
      img.empty? ? [] : [img[0]['src']]
    end

    def name_files
      unless @urls.empty?
        @name ||= @workers.sanitize(@author)
        ["#{@type.to_s}-#{@name}-#{@workers.timed}.jpg"]
      else
        []
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.1.6 lib/nokaya/favd.rb