Class: Embedit::Oembed

Inherits:
Object
  • Object
show all
Defined in:
lib/embedit/providers/oembed.rb

Constant Summary collapse

@@list =
{
  /flickr\.com\/photos\/(\S+)\/([0-9A-Za-z]+)/xi => { :name => "flickr", :api_url => "http://www.flickr.com/services/oembed" },
  /pownce/ => { :name => "pownce", :api_url => "http://api.pownce.com/2.1/oembed.{format}" },
  /revision3/ => { :name => "pownce", :api_url => "http://revision3.com/api/oembed/" },
  /qik\.com\/video\/(\d+)/xi => { :name => "qik", :api_url => "http://qik.com/api/oembed.{format}" },
  /viddler\.com(\/explore)?\/([^\/,\s]+)\/videos\/([^\/,\s]+)/xi => { :name => "viddler", :api_url => "http://lab.viddler.com/services/oembed/" },
  /vimeo\.com\/(\d+)/xi => { :name => "vimeo", :api_url => "http://www.vimeo.com/api/oembed.{format}" },
  /slideshare/ => {:name => "slideshare", :api_url => "http://oohembed.com/oohembed/"},
  /amazon\.(com|co.uk|de|ca|jp)\/(.*)(gp\/product|o\/ASIN|obidos\/ASIN|dp)\/(.*)/ => {:name => "amazon", :api_url => "http://oohembed.com/oohembed/"}
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Oembed

Returns a new instance of Oembed.



18
19
20
21
22
23
# File 'lib/embedit/providers/oembed.rb', line 18

def initialize(url)
  @input_url = url

  get_provider_for(url)
  get_info
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



16
17
18
# File 'lib/embedit/providers/oembed.rb', line 16

def format
  @format
end

#html(size = {}) ⇒ Object (readonly)

Returns the value of attribute html.



16
17
18
# File 'lib/embedit/providers/oembed.rb', line 16

def html
  @html
end

#titleObject (readonly)

Returns the value of attribute title.



16
17
18
# File 'lib/embedit/providers/oembed.rb', line 16

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



16
17
18
# File 'lib/embedit/providers/oembed.rb', line 16

def url
  @url
end

Class Method Details

.match(url) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/embedit/providers/oembed.rb', line 36

def self.match(url)
  @@list.keys.each do |regex|
    m = url.match(regex)
    return m if m
  end
  nil # if none matches
end