Class: SeClimbingVideos::Video

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#durationObject

Returns the value of attribute duration.



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

def duration
  @duration
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#upload_dateObject

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_userObject

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_urlObject

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

.allObject



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

.resetObject



26
27
28
# File 'lib/se_climbing_videos/video.rb', line 26

def self.reset
  @@all.clear
end

Instance Method Details

#video_docObject



34
35
36
# File 'lib/se_climbing_videos/video.rb', line 34

def video_doc
  @video_doc ||= Nokogiri::HTML(open(self.video_url))
end