Class: Redtube::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/redtube/video.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

elements_by_query, find_by_query, get, name

Constructor Details

#initialize(video) ⇒ Video

Returns a new instance of Video.



13
14
15
16
# File 'lib/redtube/video.rb', line 13

def initialize(video)
  @id = video["video_id"]
  %w(duration views rating ratings title url thumb).each { |name| send "#{name}=", video[name] }
end

Instance Attribute Details

#durationObject

Returns the value of attribute duration.



3
4
5
# File 'lib/redtube/video.rb', line 3

def duration
  @duration
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/redtube/video.rb', line 3

def id
  @id
end

#ratingObject

Returns the value of attribute rating.



3
4
5
# File 'lib/redtube/video.rb', line 3

def rating
  @rating
end

#ratingsObject

Returns the value of attribute ratings.



3
4
5
# File 'lib/redtube/video.rb', line 3

def ratings
  @ratings
end

#thumbObject

Returns the value of attribute thumb.



3
4
5
# File 'lib/redtube/video.rb', line 3

def thumb
  @thumb
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/redtube/video.rb', line 3

def title
  @title
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/redtube/video.rb', line 3

def url
  @url
end

#viewsObject

Returns the value of attribute views.



3
4
5
# File 'lib/redtube/video.rb', line 3

def views
  @views
end

Class Method Details

.find(id) ⇒ Object



5
6
7
# File 'lib/redtube/video.rb', line 5

def self.find(id)
  find_by_query("getVideoById&video_id=#{id}").first
end

.search(term) ⇒ Object



9
10
11
# File 'lib/redtube/video.rb', line 9

def self.search(term)
  find_by_query "searchVideos&search=#{term}"
end