Sha256: 51c8bd386224fe5725af0d6efd59bf6f7544198ddac43dec5e7f7ca7ba91eaea

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

# encoding: utf-8
module Nokaya

  class Favd < Basic

    attr_reader :author

    def initialize args, options = {}
      super(args, options)
      @type = :favd
      parsed = parse(args[0])
      @urls = get_favd(parsed).compact
      @author = author(parsed)
      @filenames = name_files()
    end

    private

    def author 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

2 entries across 2 versions & 1 rubygems

Version Path
nokaya-0.1.4 lib/nokaya/favd.rb
nokaya-0.1.3 lib/nokaya/favd.rb