Class: NicoQuery::ObjectMapper::GetThumbInfo
- Inherits:
-
Object
- Object
- NicoQuery::ObjectMapper::GetThumbInfo
- Defined in:
- lib/nicoquery/object_mapper/getthumbinfo.rb
Instance Method Summary collapse
- #comment_num ⇒ Object
- #description ⇒ Object
- #embeddable ⇒ Object
- #first_retrieve ⇒ Object
-
#initialize(xml) ⇒ GetThumbInfo
constructor
A new instance of GetThumbInfo.
- #last_res_body ⇒ Object
- #length ⇒ Object
- #movie_type ⇒ Object
- #mylist_counter ⇒ Object
- #no_live_play ⇒ Object
-
#publish_date ⇒ Object
alias.
- #size_high ⇒ Object
- #size_low ⇒ Object
- #tags ⇒ Object
- #thumb_type ⇒ Object
- #thumbnail_url ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #user_id ⇒ Object
- #video_id ⇒ Object
- #view_counter ⇒ Object
- #watch_url ⇒ Object
Constructor Details
#initialize(xml) ⇒ GetThumbInfo
Returns a new instance of GetThumbInfo.
8 9 10 11 12 13 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 8 def initialize(xml) @xml = xml parser = Nori.new parsed_xml = parser.parse xml @hash = parsed_xml['nicovideo_thumb_response']['thumb'] end |
Instance Method Details
#comment_num ⇒ Object
60 61 62 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 60 def comment_num @hash['comment_num'].to_i end |
#description ⇒ Object
23 24 25 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 23 def description @_description ||= Description.new @hash['description'] end |
#embeddable ⇒ Object
84 85 86 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 84 def @hash['embeddable'] == 1 end |
#first_retrieve ⇒ Object
31 32 33 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 31 def first_retrieve @hash['first_retrieve'].to_time end |
#last_res_body ⇒ Object
68 69 70 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 68 def last_res_body @hash['last_res_body'] end |
#length ⇒ Object
39 40 41 42 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 39 def length string = @hash['length'].split(':') string[0].to_i * 60 + string[1].to_i end |
#movie_type ⇒ Object
44 45 46 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 44 def movie_type @hash['movie_type'] end |
#mylist_counter ⇒ Object
64 65 66 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 64 def mylist_counter @hash['mylist_counter'].to_i end |
#no_live_play ⇒ Object
88 89 90 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 88 def no_live_play @hash['no_live_play'] == 1 end |
#publish_date ⇒ Object
alias
35 36 37 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 35 def publish_date # alias first_retrieve end |
#size_high ⇒ Object
48 49 50 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 48 def size_high @hash['size_high'].to_i end |
#size_low ⇒ Object
52 53 54 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 52 def size_low @hash['size_low'].to_i end |
#tags ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 92 def xml = @xml.scan(/\<tags domain=\"jp\">\n.+\n\<\/tags\>/m)[0] parsed = Nokogiri::XML xml parsed.xpath("//tag").map do |tag_object| generate_tag_hash_by tag_object end end |
#thumb_type ⇒ Object
80 81 82 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 80 def thumb_type @hash['thumb_type'] end |
#thumbnail_url ⇒ Object
27 28 29 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 27 def thumbnail_url @hash['thumbnail_url'] end |
#title ⇒ Object
19 20 21 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 19 def title @hash['title'] end |
#url ⇒ Object
72 73 74 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 72 def url @hash['watch_url'] end |
#user_id ⇒ Object
100 101 102 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 100 def user_id @hash['user_id'].to_i end |
#video_id ⇒ Object
15 16 17 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 15 def video_id @hash['video_id'] end |
#view_counter ⇒ Object
56 57 58 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 56 def view_counter @hash['view_counter'].to_i end |
#watch_url ⇒ Object
76 77 78 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 76 def watch_url @hash['watch_url'] end |