class NicoQuery::Object::Mylist
Attributes
movies[RW]
Public Class Methods
new(mylist_id)
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 30 def initialize(mylist_id) @movies = [] @mylist_id = mylist_id @response_xml = (NicoQuery::Api::MylistRSS.new mylist_id).get @source_object = source_object set_hash_items end
Public Instance Methods
available?()
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 38 def available? [exist?, !forbidden?].all? end
exist?()
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 46 def exist? @response_xml[:status_code] != 404 end
forbidden?()
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 42 def forbidden? @response_xml[:status_code] == 403 end
Private Instance Methods
null_response_xml()
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 68 def null_response_xml <<-EOS <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title></title> <link></link> <atom:link rel="self" type="application/rss+xml" href="http://www.nicovideo.jp/mylist/38350049?rss=2.0"/> <description></description> <pubDate></pubDate> <lastBuildDate></lastBuildDate> <generator></generator> <dc:creator></dc:creator> <language></language> <copyright></copyright> <docs></docs> </channel> </rss> EOS end
set_hash_items()
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 60 def set_hash_items @source_object.items.each do |item| movie = NicoQuery::Object::Movie.new item.video_id.presence || item.thread_id movie.set_mylist_rss_source item @movies.push movie end end
source_object()
click to toggle source
# File lib/nicoquery/object/mylist.rb, line 52 def source_object if available? NicoQuery::ObjectMapper::MylistRSS.new @response_xml[:body] else NicoQuery::ObjectMapper::MylistRSS.new null_response_xml end end