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.
73 74 75 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 73 def initialize(parsed_xml) @hash = parsed_xml end |
Instance Method Details
#comment_num ⇒ Object
106 107 108 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 106 def comment_num description.raw_text.scan(/(?<=nico-numbers-res\">)[0-9,]{1,}(?=\<\/strong)/)[0].delete(',').to_i end |
#description ⇒ Object
114 115 116 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 114 def description @_description ||= Description.new @hash['description'] end |
#length ⇒ Object
118 119 120 121 122 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 118 def length 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
110 111 112 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 110 def mylist_counter description.raw_text.scan(/(?<=nico-numbers-mylist\">)[0-9,]{1,}(?=\<\/strong)/)[0].delete(',').to_i end |
#publish_date ⇒ Object
93 94 95 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 93 def publish_date Time.parse @hash['pubDate'] end |
#thread_id ⇒ Object
89 90 91 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 89 def thread_id @hash['guid'].scan(/(?<=watch\/)\d{1,}$/)[0].to_i end |
#thumbnail_url ⇒ Object
97 98 99 100 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 97 def thumbnail_url description.raw_text.scan(/(?<=src\=\").{1,}(?=\"\swidth)/)[0] $& end |
#title ⇒ Object
77 78 79 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 77 def title @hash['title'] end |
#url ⇒ Object
85 86 87 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 85 def url @hash['link'] end |
#video_id ⇒ Object
81 82 83 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 81 def video_id (url.scan(/((sm|nm)\d{1,})/).map {|e| e[0]})[0] end |
#view_counter ⇒ Object
102 103 104 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 102 def view_counter description.raw_text.scan(/(?<=nico-numbers-view\">)[0-9,]{1,}(?=\<\/strong)/)[0].delete(',').to_i end |