class Nokaya::Favd

Attributes

author[R]

Public Class Methods

new(args, options = {}) click to toggle source
Calls superclass method Nokaya::Basic::new
# File lib/nokaya/favd.rb, line 8
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 Instance Methods

author_name(page) click to toggle source
# File lib/nokaya/favd.rb, line 24
def author_name page
  username = page.css('.username')
  username.empty? ? [] : username[0].text
end
get_favd(page) click to toggle source
# File lib/nokaya/favd.rb, line 29
def get_favd page
  img = page.css('#largeImage')
  img.empty? ? [] : [img[0]['src']]
end
name_files() click to toggle source
# File lib/nokaya/favd.rb, line 34
def name_files
  unless @urls.empty?
    @name ||= @workers.sanitize(@author)
    ["#{@type.to_s}-#{@name}-#{@workers.timed}.jpg"]
  else
    []
  end
end