class NicoQuery::ObjectMapper::VideoArray
Attributes
movies[R]
Public Class Methods
new(xml)
click to toggle source
# File lib/nicoquery/object_mapper/video_array.rb, line 10 def initialize(xml) parser = Nori.new parsed_xml = parser.parse xml entire = parsed_xml['nicovideo_video_response'] if entire['video_info'].is_a? Array @movies = entire['video_info'].each_with_object([]) do |movie, array| array << Video.new(movie) end elsif entire['video_info'].nil? @movies = [] else # noriは子要素が複数の場合は配列に変換するが、1つの場合には配列にしない。 # しかし、MylistRSSはitemsが配列であること前提にしているので、item要素が # 1つだけの場合にも配列に変換する必要がある。 @movies = [ Video.new(entire['video_info']) ] end end