Module: Conred::Video

Included in:
Other, Vimeo, Youtube
Defined in:
lib/conred/video.rb

Defined Under Namespace

Classes: Other, Vimeo, Youtube

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(arguments) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/conred/video.rb', line 14

def self.new arguments
  if Youtube.url_format_is_valid? arguments[:video_url]
    Youtube.new arguments
  elsif Video::Vimeo.url_format_is_valid? arguments[:video_url]
    Vimeo.new arguments
  else
    Other.new arguments
  end
end

Instance Method Details

#codeObject



32
33
34
35
36
37
38
# File 'lib/conred/video.rb', line 32

def code
  render(
    :video_link => video_link,
    :height => @height,
    :width => @width
  ).html_safe
end

#exist?Boolean



40
41
42
43
# File 'lib/conred/video.rb', line 40

def exist?
  response = Typhoeus.get("https:#{api_uri}")
  response.code == 200
end

#initialize(arguments = {:width => 670, :height => 450, :error_message => "Video url you have provided is invalid"}) ⇒ Object



7
8
9
10
11
12
# File 'lib/conred/video.rb', line 7

def initialize(arguments = {:width => 670, :height => 450, :error_message => "Video url you have provided is invalid"})
  @width = arguments[:width]
  @height = arguments[:height]
  @error_message = arguments[:error_message]
  @video_id = get_video_id_from arguments[:video_url]
end

#vimeo_video?Boolean



28
29
30
# File 'lib/conred/video.rb', line 28

def vimeo_video?
  is_a?(Video::Vimeo)
end

#youtube_video?Boolean



24
25
26
# File 'lib/conred/video.rb', line 24

def youtube_video?
  is_a?(Video::Youtube)
end