Class: Html2rss::Rendering::AudioRenderer

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(url:, type:) ⇒ AudioRenderer

Returns a new instance of AudioRenderer.

Parameters:

  • url (String, Html2rss::Url)

    media URL for the audio source

  • type (String)

    MIME type for the audio source



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

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

Instance Method Details

#to_htmlString

Returns HTML audio snippet for article rendering.

Returns:

  • (String)

    HTML audio snippet for article rendering



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

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