Class: Lumiere::YouTube
Constant Summary
collapse
- USEABLE =
['www.youtube.com', 'youtube.com', 'youtu.be']
Constants inherited
from Provider
Provider::PROVIDERS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from EmbedCode
#embed_code
Methods inherited from Provider
#==, #accessible?, delegate, #embed_code, #playlist_id, #videos
Constructor Details
#initialize(url, fetched = nil) ⇒ YouTube
Returns a new instance of YouTube.
17
18
19
20
|
# File 'lib/provider/youtube/youtube.rb', line 17
def initialize(url, fetched=nil)
@url = url
@fetched = fetched
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3
4
5
|
# File 'lib/provider/youtube/youtube.rb', line 3
def url
@url
end
|
Class Method Details
.new_from_video_id(video_id, fetched = nil) ⇒ Object
13
14
15
|
# File 'lib/provider/youtube/youtube.rb', line 13
def self.new_from_video_id(video_id, fetched=nil)
new("http://www.youtube.com/watch?v=#{video_id}")
end
|
.useable?(url) ⇒ Boolean
8
9
10
11
|
# File 'lib/provider/youtube/youtube.rb', line 8
def self.useable?(url)
uri = URISchemeless.parse(url)
USEABLE.include?(uri.host)
end
|
Instance Method Details
#api_url ⇒ Object
30
31
32
|
# File 'lib/provider/youtube/youtube.rb', line 30
def api_url
"http://gdata.youtube.com/feeds/api/videos/#{video_id}?v=2&alt=json"
end
|
#default_attributes ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/provider/youtube/youtube.rb', line 38
def default_attributes
{ iframe_attributes:
{
frameborder: 0,
allowfullscreen: true
}
}
end
|
#description ⇒ Object
63
64
65
|
# File 'lib/provider/youtube/youtube.rb', line 63
def description
fetch.description
end
|
#duration ⇒ Object
67
68
69
|
# File 'lib/provider/youtube/youtube.rb', line 67
def duration
fetch.duration
end
|
#embed_url ⇒ Object
34
35
36
|
# File 'lib/provider/youtube/youtube.rb', line 34
def embed_url
"//www.youtube.com/embed/#{video_id}"
end
|
#provider ⇒ Object
22
23
24
|
# File 'lib/provider/youtube/youtube.rb', line 22
def provider
"YouTube"
end
|
#thumbnail_large ⇒ Object
55
56
57
|
# File 'lib/provider/youtube/youtube.rb', line 55
def thumbnail_large
fetch.thumbnails[2].url
end
|
#thumbnail_medium ⇒ Object
51
52
53
|
# File 'lib/provider/youtube/youtube.rb', line 51
def thumbnail_medium
fetch.thumbnails[1].url
end
|
#thumbnail_small ⇒ Object
47
48
49
|
# File 'lib/provider/youtube/youtube.rb', line 47
def thumbnail_small
fetch.thumbnails[0].url
end
|
#title ⇒ Object
59
60
61
|
# File 'lib/provider/youtube/youtube.rb', line 59
def title
fetch.title
end
|
#unpack_into ⇒ Object
75
76
77
78
|
# File 'lib/provider/youtube/youtube.rb', line 75
def unpack_into
struct = OpenStruct.new
struct.extend(YouTubeVideoEntryRepresenter)
end
|
#upload_date ⇒ Object
71
72
73
|
# File 'lib/provider/youtube/youtube.rb', line 71
def upload_date
fetch.upload_date
end
|
#video_id ⇒ Object
26
27
28
|
# File 'lib/provider/youtube/youtube.rb', line 26
def video_id
@video_id ||= calculate_video_id
end
|