Class: FilmSnob::VideoSite

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

Overview

TODO(2015-11-15): rename to something more general we’re using this for things like Instagram

Constant Summary collapse

SUBCLASSES =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of VideoSite.



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

def initialize(url, options = {})
  @url = url
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/film_snob/video_site.rb', line 8

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/film_snob/video_site.rb', line 8

def url
  @url
end

Class Method Details

.httpObject



39
40
41
42
43
# File 'lib/film_snob/video_site.rb', line 39

def self.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/video_site.rb', line 23

def self.inherited(base)
  SUBCLASSES << base
end

.oembed_endpointObject



35
36
37
# File 'lib/film_snob/video_site.rb', line 35

def self.oembed_endpoint
  ""
end

.subclassesObject



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

def self.subclasses
  SUBCLASSES
end

.use_ssl?Boolean

Returns:

  • (Boolean)


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

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

.valid_url_patternsObject



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

def self.valid_url_patterns
  []
end

Instance Method Details

#htmlObject



53
54
55
# File 'lib/film_snob/video_site.rb', line 53

def html
  lookup :html
end

#idObject



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

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

#siteObject



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

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

#titleObject



49
50
51
# File 'lib/film_snob/video_site.rb', line 49

def title
  lookup :title
end