Class: Nicovideo::OpenList

Inherits:
Page
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nicovideo/openlist.rb

Overview

This class doesn’t access NICONICO DOUGA when an instance created. At the first time you call this instance method, this accesses NICONICO

Constant Summary

Constants inherited from Page

Page::BASE_TITLE1, Page::BASE_TITLE2, Page::BASE_URL, Page::NV_DEBUG_LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Page

#exists?, #html, #title=

Constructor Details

#initialize(agent, video_id, sort = 'c', order = 'd', pagenum = 1) ⇒ OpenList

Returns a new instance of OpenList.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nicovideo/openlist.rb', line 10

def initialize agent, video_id, sort='c', order='d', pagenum=1
  super(agent)
  @video_id = video_id
  @pagenum  = pagenum
  @sort     = sort
  @order    = order
  @url      = url()

  params = ["mylists", "total_size", "has_next?", "has_prev?"]
  self.register_getter params
end

Instance Attribute Details

#pagenumObject

Returns the value of attribute pagenum.



22
23
24
# File 'lib/nicovideo/openlist.rb', line 22

def pagenum
  @pagenum
end

Instance Method Details

#eachObject



31
32
33
34
35
# File 'lib/nicovideo/openlist.rb', line 31

def each
  self.mylists.each {|ml|
    yield ml
  }
end

#idObject



24
# File 'lib/nicovideo/openlist.rb', line 24

def id() @video_id end

#nextObject



52
53
54
55
# File 'lib/nicovideo/openlist.rb', line 52

def next
  self.pagenum = @pagenum + 1
  self
end

#page=(pagenum) ⇒ Object



47
48
49
50
# File 'lib/nicovideo/openlist.rb', line 47

def page=(pagenum)
  self.pagenum = pagenum
  self
end

#prevObject



57
58
59
60
# File 'lib/nicovideo/openlist.rb', line 57

def prev
  self.pagenum = @pagenum - 1
  self
end

#to_aObject



37
# File 'lib/nicovideo/openlist.rb', line 37

def to_a() self.mylists end

#urlObject

call whenever pagenum changed



27
28
29
# File 'lib/nicovideo/openlist.rb', line 27

def url
  @url = BASE_URL + '/openlist/' + @video_id + "?page=#{@pagenum}&sort=#{@sort}&order=#{@order}"
end