Class: Html2rss::Rendering::VideoRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/rendering/video_renderer.rb

Overview

Renders an HTML <video> tag from a URL and type.

Instance Method Summary collapse

Constructor Details

#initialize(url:, type:) ⇒ VideoRenderer

Returns a new instance of VideoRenderer.

Parameters:

  • url (String, Html2rss::Url)

    media URL for the video source

  • type (String)

    MIME type for the video source



11
12
13
14
# File 'lib/html2rss/rendering/video_renderer.rb', line 11

def initialize(url:, type:)
  @url = url
  @type = type
end

Instance Method Details

#to_htmlString

Returns HTML video snippet for article rendering.

Returns:

  • (String)

    HTML video snippet for article rendering



17
18
19
20
21
22
23
# File 'lib/html2rss/rendering/video_renderer.rb', line 17

def to_html
  [
    '<video controls preload="none" referrerpolicy="no-referrer" crossorigin="anonymous" playsinline>',
    %(<source src="#{escaped_url}" type="#{escaped_type}">),
    '</video>'
  ].join
end