class Nicovideo::Ranking
Public Class Methods
new(agent, type='mylist', span='daily', category='all', pagenum=nil)
click to toggle source
Calls superclass method
Nicovideo::Page.new
# File lib/nicovideo/ranking.rb, line 3 def initialize agent, type='mylist', span='daily', category='all', pagenum=nil super(agent) @type = type @category = category @pagenum = pagenum @url = url() self.register_getter ["videos"] end
Public Instance Methods
to_a()
click to toggle source
# File lib/nicovideo/ranking.rb, line 20 def to_a videos() end
url()
click to toggle source
# File lib/nicovideo/ranking.rb, line 12 def url url = "#{BASE_URL}/ranking/#{@type}/#{@span}/#{@category}" if @pagenum url += '?page=' + @pagenum.to_s end url end
Protected Instance Methods
parse(page)
click to toggle source
# File lib/nicovideo/ranking.rb, line 25 def parse(page) ranking = page/'h3/a[@class=video]' @videos = ranking.inject([]) {|arr,v| # #puts v.attributes['href'] vp = VideoPage.new(@agent, v.attributes['href'].sub(/#{BASE_URL}\/watch\/(\w+)$/,'\1')) vp.title = v.inner_html arr << vp } end