class Nokaya::Basic
Attributes
args[R]
filenames[R]
name[R]
options[R]
path[R]
type[R]
urls[RW]
Public Class Methods
new(args, options)
click to toggle source
# File lib/nokaya/basic.rb, line 9 def initialize args, options Logs.create_logger @options = options @workers = Workers.new(options) @args = args @filenames = [] @urls = [] @path = @workers.path @type = :basic @name = options['name'] if options['name'] @platform = RbConfig::CONFIG['host_os'] end
Public Instance Methods
get_basic(page)
click to toggle source
# File lib/nokaya/basic.rb, line 22 def get_basic page page.xpath("//meta[@property='og:image']/@content").first.value unless page.nil? end
name_files()
click to toggle source
# File lib/nokaya/basic.rb, line 48 def name_files @urls.map do |url| "#{@type.to_s}-#{@author}-#{File.basename(url)}" end end
parse(url)
click to toggle source
# File lib/nokaya/basic.rb, line 26 def parse url begin Nokogiri::HTML(open url) rescue Errno::ENOENT => e Logs.rec.error e puts Status.no_url if options['verbose'] return nil rescue OpenURI::HTTPError => e Logs.rec.error e puts Status.no_can_do if options['verbose'] return nil rescue Exception => e Logs.rec.error e puts Status.error if options['verbose'] return nil end end
save()
click to toggle source
# File lib/nokaya/basic.rb, line 44 def save @workers.save(self) end