Class: VideoEmbed

Inherits:
Object
  • Object
show all
Defined in:
lib/video_embed.rb,
lib/video_embed/vimeo.rb,
lib/video_embed/version.rb,
lib/video_embed/youtube.rb,
lib/video_embed/no_service.rb

Defined Under Namespace

Classes: NoService, Vimeo, YouTube

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(services = nil) ⇒ VideoEmbed

Returns a new instance of VideoEmbed.



11
12
13
14
15
16
17
# File 'lib/video_embed.rb', line 11

def initialize(services = nil)
  if services.nil?
    @services = default_services
  else
    @services = services
  end
end

Instance Attribute Details

#servicesObject (readonly)

Returns the value of attribute services.



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

def services
  @services
end

Class Method Details

.embed(url, options = {}) ⇒ Object



27
28
29
30
# File 'lib/video_embed.rb', line 27

def self.embed(url, options = {})
  video_embed = new
  video_embed.embed(url, options)
end

Instance Method Details

#embed(url, options = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/video_embed.rb', line 19

def embed(url, options = {})
  if url.is_a? String
    url = URI.parse(url)
  end
  service = find_service_by_url(url)
  service.embed(url, options)
end