class SocialParser::Provider::Youtube
Constants
- URL_FORMATS
Public Instance Methods
embed_url()
click to toggle source
Calls superclass method
SocialParser::Provider::Base#embed_url
# File lib/social_parser/provider/youtube.rb, line 29 def embed_url return super unless video? "https://www.youtube.#{domain}/embed/#{username}" end
provider()
click to toggle source
# File lib/social_parser/provider/youtube.rb, line 13 def provider :youtube end
type()
click to toggle source
# File lib/social_parser/provider/youtube.rb, line 17 def type @type || 'user' end
url()
click to toggle source
# File lib/social_parser/provider/youtube.rb, line 21 def url if video? "https://www.youtube.#{domain}/watch?v=#{username}" else "https://www.youtube.#{domain}/#{type}/#{username}" end end
Private Instance Methods
parse_from_url()
click to toggle source
# File lib/social_parser/provider/youtube.rb, line 40 def parse_from_url URL_FORMATS.each do |key, format| m = format.match(url_from_attributes) next unless m if key == :full @type = m[:type] return nil if @type != 'user' elsif key == :video || key == :embed @type = 'video' end return m[:id] end nil end
video?()
click to toggle source
# File lib/social_parser/provider/youtube.rb, line 36 def video? type == 'video' end