Class: RichUrls::Parsers::EmbedParser

Inherits:
Object
  • Object
show all
Defined in:
lib/parsers/embed_parser.rb,
lib/parsers/embed_parsers/base.rb,
lib/parsers/embed_parsers/paste.rb,
lib/parsers/embed_parsers/spotify.rb,
lib/parsers/embed_parsers/youtube.rb,
lib/parsers/embed_parsers/youtube_short.rb

Defined Under Namespace

Classes: Base, Paste, Spotify, Youtube, YoutubeShort

Constant Summary collapse

PARSERS =
[
  Youtube,
  YoutubeShort,
  Paste,
  Spotify
].freeze

Class Method Summary collapse

Class Method Details

.call(_, url) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/parsers/embed_parser.rb', line 17

def self.call(_, url)
  uri = URI(url)

  PARSERS.each do |parser|
    embed_parser = parser.new(uri)

    return embed_parser.parse if embed_parser.match?
  end

  nil
end