Class: RichUrls::Parsers::EmbedParser::Youtube

Inherits:
Base
  • Object
show all
Defined in:
lib/parsers/embed_parsers/youtube.rb

Constant Summary collapse

IFRAME =
'<iframe width="560" height="315" '\
'src="https://www.youtube.com/embed/%s" frameborder="0" '\
'allow="accelerometer; autoplay; encrypted-media; '\
'gyroscope; picture-in-picture" allowfullscreen>'\
'</iframe>'.freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RichUrls::Parsers::EmbedParser::Base

Instance Method Details

#match?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/parsers/embed_parsers/youtube.rb', line 11

def match?
  @uri.host == 'www.youtube.com' &&
    @uri.path == '/watch' &&
    query.key?('v')
end

#parseObject



17
18
19
# File 'lib/parsers/embed_parsers/youtube.rb', line 17

def parse
  IFRAME % query.fetch('v')
end