Class: SeClimbingVideos::Video
- Inherits:
-
Object
- Object
- SeClimbingVideos::Video
- Defined in:
- lib/se_climbing_videos/video.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#upload_date ⇒ Object
Returns the value of attribute upload_date.
-
#upload_user ⇒ Object
Returns the value of attribute upload_user.
-
#video_url ⇒ Object
Returns the value of attribute video_url.
Class Method Summary collapse
- .all ⇒ Object
- .find(input) ⇒ Object
- .new_from_youtube_list(video, location) ⇒ Object
- .reset ⇒ Object
Instance Method Summary collapse
-
#initialize(name = nil, upload_user = nil, duration = nil, video_url = nil, location = nil) ⇒ Video
constructor
A new instance of Video.
- #video_doc ⇒ Object
Constructor Details
#initialize(name = nil, upload_user = nil, duration = nil, video_url = nil, location = nil) ⇒ Video
Returns a new instance of Video.
13 14 15 16 17 18 19 20 |
# File 'lib/se_climbing_videos/video.rb', line 13 def initialize(name=nil, upload_user=nil, duration=nil, video_url=nil, location=nil) @name = name @upload_user = upload_user @duration = duration @video_url = video_url @location = location @@all << self unless @@all.include?(self) end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def description @description end |
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def duration @duration end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def name @name end |
#upload_date ⇒ Object
Returns the value of attribute upload_date.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def upload_date @upload_date end |
#upload_user ⇒ Object
Returns the value of attribute upload_user.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def upload_user @upload_user end |
#video_url ⇒ Object
Returns the value of attribute video_url.
3 4 5 |
# File 'lib/se_climbing_videos/video.rb', line 3 def video_url @video_url end |
Class Method Details
.all ⇒ Object
22 23 24 |
# File 'lib/se_climbing_videos/video.rb', line 22 def self.all @@all end |
.find(input) ⇒ Object
30 31 32 |
# File 'lib/se_climbing_videos/video.rb', line 30 def self.find(input) self.all[input.to_i-1] end |
.new_from_youtube_list(video, location) ⇒ Object
7 8 9 10 11 |
# File 'lib/se_climbing_videos/video.rb', line 7 def self.new_from_youtube_list(video, location) self.new( video.search("a.yt-uix-tile-link").attr("title").text, video.search("div.yt-lockup-byline").text, video.search("span.accessible-description").text.gsub(" - Duration: ", "").gsub(".", ""), ("https://www.youtube.com" + video.search("a.yt-uix-tile-link").attr("href").value), location ) end |
.reset ⇒ Object
26 27 28 |
# File 'lib/se_climbing_videos/video.rb', line 26 def self.reset @@all.clear end |
Instance Method Details
#video_doc ⇒ Object
34 35 36 |
# File 'lib/se_climbing_videos/video.rb', line 34 def video_doc @video_doc ||= Nokogiri::HTML(open(self.video_url)) end |