Class: FilmSnob::OembedProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/film_snob/oembed_provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ OembedProvider

Returns a new instance of OembedProvider.



8
9
10
11
12
# File 'lib/film_snob/oembed_provider.rb', line 8

def initialize(url, options = {})
  @url = url
  @options = friendly_options(options)
  ensure_match unless options.delete(:matched)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/film_snob/oembed_provider.rb', line 6

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/film_snob/oembed_provider.rb', line 6

def url
  @url
end

Class Method Details

.httpObject



35
36
37
38
39
# File 'lib/film_snob/oembed_provider.rb', line 35

def http
  Net::HTTP.new(uri.host, uri.port).tap do |uri|
    uri.use_ssl = use_ssl?
  end
end

.inherited(base) ⇒ Object



23
24
25
# File 'lib/film_snob/oembed_provider.rb', line 23

def inherited(base)
  subclasses << base
end

.oembed_endpointObject



31
32
33
# File 'lib/film_snob/oembed_provider.rb', line 31

def oembed_endpoint
  ""
end

.subclassesObject



45
46
47
# File 'lib/film_snob/oembed_provider.rb', line 45

def subclasses
  @subclasses ||= []
end

.use_ssl?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/film_snob/oembed_provider.rb', line 41

def use_ssl?
  "https" == uri.scheme
end

.valid_url_patternsObject



27
28
29
# File 'lib/film_snob/oembed_provider.rb', line 27

def valid_url_patterns
  []
end

Instance Method Details

#htmlObject



60
61
62
# File 'lib/film_snob/oembed_provider.rb', line 60

def html
  lookup :html
end

#idObject



14
15
16
# File 'lib/film_snob/oembed_provider.rb', line 14

def id
  @id ||= matching_pattern.match(url)[1]
end

#siteObject



18
19
20
# File 'lib/film_snob/oembed_provider.rb', line 18

def site
  @site ||= self.class.to_s.split("::").last.downcase.to_sym
end

#titleObject



56
57
58
# File 'lib/film_snob/oembed_provider.rb', line 56

def title
  lookup :title
end