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
- #generate_tag_hash_by(nokogiri_xml) ⇒ 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.
7 8 9 10 11 12 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 7 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
59 60 61 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 59 def comment_num @hash['comment_num'].to_i end |
#description ⇒ Object
22 23 24 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 22 def description @hash['description'] end |
#embeddable ⇒ Object
83 84 85 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 83 def @hash['embeddable'] == 1 end |
#first_retrieve ⇒ Object
30 31 32 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 30 def first_retrieve @hash['first_retrieve'].to_time end |
#generate_tag_hash_by(nokogiri_xml) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 103 def generate_tag_hash_by(nokogiri_xml) text = nokogiri_xml.text lock = if nokogiri_xml.attributes['lock'].present? nokogiri_xml.attributes['lock'].text.to_i == 1 else false end { text: text, lock: lock } end |
#last_res_body ⇒ Object
67 68 69 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 67 def last_res_body @hash['last_res_body'] end |
#length ⇒ Object
38 39 40 41 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 38 def length string = @hash['length'].split(':') string[0].to_i * 60 + string[1].to_i end |
#movie_type ⇒ Object
43 44 45 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 43 def movie_type @hash['movie_type'] end |
#mylist_counter ⇒ Object
63 64 65 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 63 def mylist_counter @hash['mylist_counter'].to_i end |
#no_live_play ⇒ Object
87 88 89 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 87 def no_live_play @hash['no_live_play'] == 1 end |
#publish_date ⇒ Object
alias
34 35 36 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 34 def publish_date # alias first_retrieve end |
#size_high ⇒ Object
47 48 49 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 47 def size_high @hash['size_high'].to_i end |
#size_low ⇒ Object
51 52 53 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 51 def size_low @hash['size_low'].to_i end |
#tags ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 91 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
79 80 81 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 79 def thumb_type @hash['thumb_type'] end |
#thumbnail_url ⇒ Object
26 27 28 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 26 def thumbnail_url @hash['thumbnail_url'] end |
#title ⇒ Object
18 19 20 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 18 def title @hash['title'] end |
#url ⇒ Object
71 72 73 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 71 def url @hash['watch_url'] end |
#user_id ⇒ Object
99 100 101 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 99 def user_id @hash['user_id'].to_i end |
#video_id ⇒ Object
14 15 16 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 14 def video_id @hash['video_id'] end |
#view_counter ⇒ Object
55 56 57 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 55 def view_counter @hash['view_counter'].to_i end |
#watch_url ⇒ Object
75 76 77 |
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 75 def watch_url @hash['watch_url'] end |