Class: NicoQuery::ObjectMapper::VideoArray::Video

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

Instance Method Summary collapse

Constructor Details

#initialize(parsed_xml) ⇒ Video

Returns a new instance of Video.



30
31
32
# File 'lib/nicoquery/object_mapper/video_array.rb', line 30

def initialize(parsed_xml)
  @hash = parsed_xml
end

Instance Method Details

#comment_numObject



79
80
81
# File 'lib/nicoquery/object_mapper/video_array.rb', line 79

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

#community?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/nicoquery/object_mapper/video_array.rb', line 34

def community?
  @hash['thread']['community_id'].present?
end

#community_idObject



91
92
93
# File 'lib/nicoquery/object_mapper/video_array.rb', line 91

def community_id
  @hash['thread']['community_id'].to_i
end

#descriptionObject



50
51
52
# File 'lib/nicoquery/object_mapper/video_array.rb', line 50

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

#first_retrieveObject



58
59
60
# File 'lib/nicoquery/object_mapper/video_array.rb', line 58

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

#lengthObject



66
67
68
69
# File 'lib/nicoquery/object_mapper/video_array.rb', line 66

def length
  string = @hash['video']['length'].split(':')
  string[0].to_i * 60 + string[1].to_i
end

#movie_typeObject



71
72
73
# File 'lib/nicoquery/object_mapper/video_array.rb', line 71

def movie_type
  @hash['video']['movie_type']
end

#mylist_counterObject



83
84
85
# File 'lib/nicoquery/object_mapper/video_array.rb', line 83

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

#publish_dateObject

alias



62
63
64
# File 'lib/nicoquery/object_mapper/video_array.rb', line 62

def publish_date # alias
  first_retrieve
end

#size_lowObject



87
88
89
# File 'lib/nicoquery/object_mapper/video_array.rb', line 87

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

#tagsObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/nicoquery/object_mapper/video_array.rb', line 95

def tags
  tag_obj = @hash['tags']['tag_info']

  if tag_obj.nil?
    tag_array = []
  elsif tag_obj.instance_of? Array
    tag_array = tag_obj
  else
    tag_array = [ tag_obj ]
  end

  tag_array.each_with_object([]) do |tag, array|
    array << { text: tag['tag'] }
  end
end

#thread_idObject



42
43
44
# File 'lib/nicoquery/object_mapper/video_array.rb', line 42

def thread_id
  @hash['thread']['id'].to_i
end

#thumbnail_urlObject



54
55
56
# File 'lib/nicoquery/object_mapper/video_array.rb', line 54

def thumbnail_url
  @hash['video']['thumbnail_url']
end

#titleObject



46
47
48
# File 'lib/nicoquery/object_mapper/video_array.rb', line 46

def title
  @hash['video']['title']
end

#video_idObject



38
39
40
# File 'lib/nicoquery/object_mapper/video_array.rb', line 38

def video_id
  @hash['video']['id']
end

#view_counterObject



75
76
77
# File 'lib/nicoquery/object_mapper/video_array.rb', line 75

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