Class: NicoQuery::ObjectMapper::GetThumbInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/nicoquery/object_mapper/getthumbinfo.rb

Instance Method Summary collapse

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_numObject



60
61
62
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 60

def comment_num
  @hash['comment_num'].to_i
end

#descriptionObject



23
24
25
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 23

def description
  @_description ||= Description.new @hash['description']
end

#embeddableObject



84
85
86
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 84

def embeddable
  @hash['embeddable'] == 1
end

#first_retrieveObject



31
32
33
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 31

def first_retrieve
  @hash['first_retrieve'].to_time
end

#last_res_bodyObject



68
69
70
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 68

def last_res_body
  @hash['last_res_body']
end

#lengthObject



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_typeObject



44
45
46
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 44

def movie_type
  @hash['movie_type']
end

#mylist_counterObject



64
65
66
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 64

def mylist_counter
  @hash['mylist_counter'].to_i
end

#no_live_playObject



88
89
90
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 88

def no_live_play
  @hash['no_live_play'] == 1
end

#publish_dateObject

alias



35
36
37
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 35

def publish_date # alias
  first_retrieve
end

#size_highObject



48
49
50
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 48

def size_high
  @hash['size_high'].to_i
end

#size_lowObject



52
53
54
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 52

def size_low
  @hash['size_low'].to_i
end

#tagsObject



92
93
94
95
96
97
98
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 92

def tags
  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_typeObject



80
81
82
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 80

def thumb_type
  @hash['thumb_type']
end

#thumbnail_urlObject



27
28
29
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 27

def thumbnail_url
  @hash['thumbnail_url']
end

#titleObject



19
20
21
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 19

def title
  @hash['title']
end

#urlObject



72
73
74
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 72

def url
  @hash['watch_url']
end

#user_idObject



100
101
102
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 100

def user_id
  @hash['user_id'].to_i
end

#video_idObject



15
16
17
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 15

def video_id
  @hash['video_id']
end

#view_counterObject



56
57
58
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 56

def view_counter
  @hash['view_counter'].to_i
end

#watch_urlObject



76
77
78
# File 'lib/nicoquery/object_mapper/getthumbinfo.rb', line 76

def watch_url
  @hash['watch_url']
end