Class: NicoQuery::ObjectMapper::MylistRSS::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/nicoquery/object_mapper/mylist_rss.rb

Defined Under Namespace

Classes: Description

Instance Method Summary collapse

Constructor Details

#initialize(parsed_xml) ⇒ Item

Returns a new instance of Item.



78
79
80
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 78

def initialize(parsed_xml)
  @hash = parsed_xml
end

Instance Method Details

#comment_numObject



118
119
120
121
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 118

def comment_num
  return nil if @hash == nil
  description.raw_text.scan(/(?<=nico-numbers-res\">)[0-9,]{1,}(?=\<\/strong)/)[0].delete(',').to_i
end

#descriptionObject



128
129
130
131
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 128

def description
  return nil if @hash == nil
  @_description ||= Description.new @hash['description']
end

#lengthObject



133
134
135
136
137
138
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 133

def length
  return nil if @hash == nil
  description.raw_text.scan(/(?<=class\=\"nico\-info\-length\"\>)\d{1,}\:\d{1,2}(?=\<\/strong\>)/)
  length_string = $&.to_s.split(':')
  length_string[0].to_i * 60 + length_string[1].to_i
end

#mylist_counterObject



123
124
125
126
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 123

def mylist_counter
  return nil if @hash == nil
  description.raw_text.scan(/(?<=nico-numbers-mylist\">)[0-9,]{1,}(?=\<\/strong)/)[0].delete(',').to_i
end

#publish_dateObject



102
103
104
105
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 102

def publish_date
  return nil if @hash == nil
  Time.parse @hash['pubDate']
end

#thread_idObject



97
98
99
100
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 97

def thread_id
  return nil if @hash == nil
  @hash['guid'].scan(/(?<=watch\/)\d{1,}$/)[0].to_i
end

#thumbnail_urlObject



107
108
109
110
111
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 107

def thumbnail_url
  return nil if @hash == nil
  description.raw_text.scan(/(?<=src\=\").{1,}(?=\"\swidth)/)[0]
  $&
end

#titleObject



82
83
84
85
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 82

def title
  return nil if @hash == nil
  @hash['title']
end

#urlObject



92
93
94
95
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 92

def url
  return nil if @hash == nil
  @hash['link']
end

#video_idObject



87
88
89
90
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 87

def video_id
  return nil if @hash == nil
  (url.scan(/((sm|nm)\d{1,})/).map {|e| e[0]})[0]
end

#view_counterObject



113
114
115
116
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 113

def view_counter
  return nil if @hash == nil
  description.raw_text.scan(/(?<=nico-numbers-view\">)[0-9,]{1,}(?=\<\/strong)/)[0].delete(',').to_i
end