Class: Html2rss::RssBuilder::Stylesheet

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/rss_builder/stylesheet.rb

Overview

Represents a stylesheet.

Constant Summary collapse

TYPES =
['text/css', 'text/xsl'].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(href:, type:, media: 'all') ⇒ Stylesheet

Returns a new instance of Stylesheet.

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
# File 'lib/html2rss/rss_builder/stylesheet.rb', line 40

def initialize(href:, type:, media: 'all')
  raise ArgumentError, 'stylesheet.href must be a String' unless href.is_a?(String)
  raise ArgumentError, 'stylesheet.type invalid' unless TYPES.include?(type)
  raise ArgumentError, 'stylesheet.media must be a String' unless media.is_a?(String)

  @href = href
  @type = type
  @media = media
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



49
50
51
# File 'lib/html2rss/rss_builder/stylesheet.rb', line 49

def href
  @href
end

#mediaObject (readonly)

Returns the value of attribute media.



49
50
51
# File 'lib/html2rss/rss_builder/stylesheet.rb', line 49

def media
  @media
end

#typeObject (readonly)

Returns the value of attribute type.



49
50
51
# File 'lib/html2rss/rss_builder/stylesheet.rb', line 49

def type
  @type
end

Class Method Details

.add(maker, stylesheets) ⇒ nil

Adds the stylesheet XML tags to the RSS.

Parameters:

  • maker (RSS::Maker::RSS20)

    RSS maker object.

  • stylesheets (Array<Html2rss::Config::Stylesheet>)

    Array of stylesheet configurations.

Returns:

  • (nil)


15
16
17
18
19
# File 'lib/html2rss/rss_builder/stylesheet.rb', line 15

def add(maker, stylesheets)
  stylesheets.each do |stylesheet|
    add_stylesheet(maker, stylesheet)
  end
end