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
- #community? ⇒ Boolean
- #deleted? ⇒ Boolean
- #description ⇒ Object
- #embeddable ⇒ Object
- #exist? ⇒ Boolean
- #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 14 15 16 17 |
# 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'] if !exist? @hash = @parser.parse null_xml end end |
Instance Method Details
#comment_num ⇒ Object
98 99 100 101 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 98 def comment_num return nil if @hash == nil @hash['comment_num'].to_i end |
#community? ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 27 def community? if @parsed_xml['nicovideo_thumb_response']["error"].presence @parsed_xml['nicovideo_thumb_response']["error"].presence["code"].presence == "COMMUNITY" else false end end |
#deleted? ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 19 def deleted? if @parsed_xml['nicovideo_thumb_response']["error"].presence @parsed_xml['nicovideo_thumb_response']["error"].presence["code"].presence == "DELETED" else false end end |
#description ⇒ Object
53 54 55 56 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 53 def description return nil if @hash.nil? || @hash['description'].nil? @_description ||= Description.new @hash['description'] end |
#embeddable ⇒ Object
128 129 130 131 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 128 def return nil if @hash == nil @hash['embeddable'] == 1 end |
#exist? ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 35 def exist? if @parsed_xml['nicovideo_thumb_response']["error"].presence @parsed_xml['nicovideo_thumb_response']["error"].presence["code"].presence != "NOT_FOUND" else true end end |
#first_retrieve ⇒ Object
63 64 65 66 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 63 def first_retrieve return nil if @hash == nil @hash['first_retrieve'].to_time end |
#last_res_body ⇒ Object
108 109 110 111 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 108 def last_res_body return nil if @hash == nil @hash['last_res_body'] end |
#length ⇒ Object
72 73 74 75 76 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 72 def length return nil if @hash == nil string = @hash['length'].split(':') string[0].to_i * 60 + string[1].to_i end |
#movie_type ⇒ Object
78 79 80 81 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 78 def movie_type return nil if @hash == nil @hash['movie_type'] end |
#mylist_counter ⇒ Object
103 104 105 106 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 103 def mylist_counter return nil if @hash == nil @hash['mylist_counter'].to_i end |
#no_live_play ⇒ Object
133 134 135 136 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 133 def no_live_play return nil if @hash == nil @hash['no_live_play'] == 1 end |
#publish_date ⇒ Object
alias
68 69 70 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 68 def publish_date # alias first_retrieve end |
#size_high ⇒ Object
83 84 85 86 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 83 def size_high return nil if @hash == nil @hash['size_high'].to_i end |
#size_low ⇒ Object
88 89 90 91 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 88 def size_low return nil if @hash == nil @hash['size_low'].to_i end |
#tags ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 138 def return nil if @hash.nil? || @hash['tags'].nil? xml = @xml.scan(/\<tags domain=\"jp\">\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
123 124 125 126 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 123 def thumb_type return nil if @hash == nil @hash['thumb_type'] end |
#thumbnail_url ⇒ Object
58 59 60 61 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 58 def thumbnail_url return nil if @hash == nil @hash['thumbnail_url'] end |
#title ⇒ Object
48 49 50 51 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 48 def title return nil if @hash == nil @hash['title'] end |
#url ⇒ Object
113 114 115 116 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 113 def url return nil if @hash == nil @hash['watch_url'] end |
#user_id ⇒ Object
147 148 149 150 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 147 def user_id return nil if @hash == nil @hash['user_id'].to_i end |
#video_id ⇒ Object
43 44 45 46 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 43 def video_id return nil if @hash == nil @hash['video_id'] end |
#view_counter ⇒ Object
93 94 95 96 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 93 def view_counter return nil if @hash.nil? || @hash['view_counter'].nil? @hash['view_counter'].to_i end |
#watch_url ⇒ Object
118 119 120 121 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 118 def watch_url return nil if @hash == nil @hash['watch_url'] end |