Class: NicoQuery::ObjectMapper::MylistRSS::Item
- Inherits:
-
Object
- Object
- NicoQuery::ObjectMapper::MylistRSS::Item
- Defined in:
- lib/nicoquery/object_mapper/mylist_rss.rb
Defined Under Namespace
Classes: Description
Instance Method Summary collapse
- #comment_num ⇒ Object
- #description ⇒ Object
-
#initialize(parsed_xml) ⇒ Item
constructor
A new instance of Item.
- #length ⇒ Object
- #mylist_counter ⇒ Object
- #publish_date ⇒ Object
- #thread_id ⇒ Object
- #thumbnail_url ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #video_id ⇒ Object
- #view_counter ⇒ Object
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_num ⇒ Object
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 |
#description ⇒ Object
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 |
#length ⇒ Object
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_counter ⇒ Object
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_date ⇒ Object
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_id ⇒ Object
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_url ⇒ Object
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 |
#title ⇒ Object
82 83 84 85 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 82 def title return nil if @hash == nil @hash['title'] end |
#url ⇒ Object
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_id ⇒ Object
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_counter ⇒ Object
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 |