Class: VideoInfo::Provider
- Inherits:
-
Object
- Object
- VideoInfo::Provider
show all
- Defined in:
- lib/video_info/provider.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(url, options = {}) ⇒ Provider
Returns a new instance of Provider.
12
13
14
15
16
|
# File 'lib/video_info/provider.rb', line 12
def initialize(url, options = {})
@options = _clean_options(options)
@url = url
_set_video_id_from_url
end
|
Instance Attribute Details
#data ⇒ Object
34
35
36
|
# File 'lib/video_info/provider.rb', line 34
def data
@data ||= _set_data_from_api
end
|
#options ⇒ Object
Returns the value of attribute options.
9
10
11
|
# File 'lib/video_info/provider.rb', line 9
def options
@options
end
|
#url ⇒ Object
Returns the value of attribute url.
9
10
11
|
# File 'lib/video_info/provider.rb', line 9
def url
@url
end
|
#video_id ⇒ Object
Returns the value of attribute video_id.
9
10
11
|
# File 'lib/video_info/provider.rb', line 9
def video_id
@video_id
end
|
Class Method Details
.usable?(_url) ⇒ Boolean
18
19
20
21
22
|
# File 'lib/video_info/provider.rb', line 18
def self.usable?(_url)
raise NotImplementedError.new(
"Provider class must implement .usable? public method"
)
end
|
Instance Method Details
#available? ⇒ Boolean
38
39
40
|
# File 'lib/video_info/provider.rb', line 38
def available?
!%w[403 404 400 451 401].include?(_response_code)
end
|
#embed_code(options = {}) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/video_info/provider.rb', line 24
def embed_code(options = {})
iframe_attributes = options.fetch(:iframe_attributes, {})
iframe_attrs = ["src=\"#{_embed_url(options)}\"", 'frameborder="0"']
iframe_attrs << _hash_to_attributes(
_default_iframe_attributes.merge(iframe_attributes)
)
"<iframe #{iframe_attrs.reject(&:empty?).join(" ")}></iframe>"
end
|
#stats ⇒ Object
56
57
58
|
# File 'lib/video_info/provider.rb', line 56
def stats
{}
end
|
#thumbnail ⇒ Object
42
43
44
45
46
|
# File 'lib/video_info/provider.rb', line 42
def thumbnail
if defined?(thumbnail_large)
thumbnail_large
end
end
|
#thumbnail_large_2x ⇒ Object
48
49
50
|
# File 'lib/video_info/provider.rb', line 48
def thumbnail_large_2x
nil
end
|
#thumbnail_maxres ⇒ Object
52
53
54
|
# File 'lib/video_info/provider.rb', line 52
def thumbnail_maxres
nil
end
|