Class: Smiling::Video
- Inherits:
-
Object
- Object
- Smiling::Video
- Defined in:
- lib/smiling/video.rb
Overview
Public: Video represents a video of Nico Nico Douga.
Instance Attribute Summary collapse
-
#comment_num ⇒ Object
readonly
Returns the value of attribute comment_num.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#embeddable ⇒ Object
readonly
Returns the value of attribute embeddable.
-
#first_retrieve ⇒ Object
readonly
Returns the value of attribute first_retrieve.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_res_body ⇒ Object
readonly
Returns the value of attribute last_res_body.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#movie_type ⇒ Object
readonly
Returns the value of attribute movie_type.
-
#mylist_counter ⇒ Object
readonly
Returns the value of attribute mylist_counter.
-
#no_live_play ⇒ Object
readonly
Returns the value of attribute no_live_play.
-
#size_high ⇒ Object
readonly
Returns the value of attribute size_high.
-
#size_low ⇒ Object
readonly
Returns the value of attribute size_low.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#thumbnail_url ⇒ Object
readonly
Returns the value of attribute thumbnail_url.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#view_counter ⇒ Object
readonly
Returns the value of attribute view_counter.
-
#watch_url ⇒ Object
readonly
Returns the value of attribute watch_url.
Instance Method Summary collapse
-
#initialize(doc) ⇒ Video
constructor
Public: Create an instance of Video.
Constructor Details
#initialize(doc) ⇒ Video
Public: Create an instance of Video.
doc - The Nokogiri::XML::Document contains response of getthumbinfo API.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/smiling/video.rb', line 29 def initialize(doc) thumb = doc.xpath('nicovideo_thumb_response/thumb') @id = thumb.xpath('video_id').text @title = thumb.xpath('title').text @description = thumb.xpath('description').text @thumbnail_url = thumb.xpath('thumbnail_url').text @first_retrieve = Time.parse(thumb.xpath('first_retrieve').text) @length = thumb.xpath('length').text @movie_type = thumb.xpath('movie_type').text @size_high = thumb.xpath('size_high').text.to_i @size_low = thumb.xpath('size_low').text.to_i @view_counter = thumb.xpath('view_counter').text.to_i @comment_num = thumb.xpath('comment_num').text.to_i @mylist_counter = thumb.xpath('mylist_counter').text.to_i @last_res_body = thumb.xpath('last_res_body').text @watch_url = thumb.xpath('watch_url').text @type = thumb.xpath('thumb_type').text @embeddable = thumb.xpath('embeddable').text @no_live_play = thumb.xpath('no_live_play').text @tags = {} thumb.xpath('tags').each do || domain = ['domain'] @tags[domain] = [] .xpath('tag').each do |tag| lock = tag['lock'] == '1' ? true : false @tags[domain] << Tag.new(value: tag.text, lock: lock) end end @user_id = thumb.xpath('user_id').text.to_i end |
Instance Attribute Details
#comment_num ⇒ Object (readonly)
Returns the value of attribute comment_num.
16 17 18 |
# File 'lib/smiling/video.rb', line 16 def comment_num @comment_num end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/smiling/video.rb', line 8 def description @description end |
#embeddable ⇒ Object (readonly)
Returns the value of attribute embeddable.
21 22 23 |
# File 'lib/smiling/video.rb', line 21 def @embeddable end |
#first_retrieve ⇒ Object (readonly)
Returns the value of attribute first_retrieve.
10 11 12 |
# File 'lib/smiling/video.rb', line 10 def first_retrieve @first_retrieve end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/smiling/video.rb', line 6 def id @id end |
#last_res_body ⇒ Object (readonly)
Returns the value of attribute last_res_body.
18 19 20 |
# File 'lib/smiling/video.rb', line 18 def last_res_body @last_res_body end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
11 12 13 |
# File 'lib/smiling/video.rb', line 11 def length @length end |
#movie_type ⇒ Object (readonly)
Returns the value of attribute movie_type.
12 13 14 |
# File 'lib/smiling/video.rb', line 12 def movie_type @movie_type end |
#mylist_counter ⇒ Object (readonly)
Returns the value of attribute mylist_counter.
17 18 19 |
# File 'lib/smiling/video.rb', line 17 def mylist_counter @mylist_counter end |
#no_live_play ⇒ Object (readonly)
Returns the value of attribute no_live_play.
22 23 24 |
# File 'lib/smiling/video.rb', line 22 def no_live_play @no_live_play end |
#size_high ⇒ Object (readonly)
Returns the value of attribute size_high.
13 14 15 |
# File 'lib/smiling/video.rb', line 13 def size_high @size_high end |
#size_low ⇒ Object (readonly)
Returns the value of attribute size_low.
14 15 16 |
# File 'lib/smiling/video.rb', line 14 def size_low @size_low end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
23 24 25 |
# File 'lib/smiling/video.rb', line 23 def @tags end |
#thumbnail_url ⇒ Object (readonly)
Returns the value of attribute thumbnail_url.
9 10 11 |
# File 'lib/smiling/video.rb', line 9 def thumbnail_url @thumbnail_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/smiling/video.rb', line 7 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/smiling/video.rb', line 20 def type @type end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
24 25 26 |
# File 'lib/smiling/video.rb', line 24 def user_id @user_id end |
#view_counter ⇒ Object (readonly)
Returns the value of attribute view_counter.
15 16 17 |
# File 'lib/smiling/video.rb', line 15 def view_counter @view_counter end |
#watch_url ⇒ Object (readonly)
Returns the value of attribute watch_url.
19 20 21 |
# File 'lib/smiling/video.rb', line 19 def watch_url @watch_url end |