Class: RichUrls::Parsers::EmbedParser::Paste

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

Constant Summary collapse

IFRAME =
'<iframe src="https://pasteapp.com/p/%s/embed?view=%s" '\
'width="480" height="480" scrolling="no" '\
'frameborder="0" 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)


9
10
11
12
13
# File 'lib/parsers/embed_parsers/paste.rb', line 9

def match?
  @uri.host == 'pasteapp.com' &&
    @uri.path =~ /\/p\/[a-zA-Z0-9]+/ &&
    !@uri.query.nil?
end

#parseObject



15
16
17
18
19
# File 'lib/parsers/embed_parsers/paste.rb', line 15

def parse
  path_id = @uri.path.sub(/\/p\//, '')

  IFRAME % [path_id, query.fetch('view')]
end