Class RSS::XMLStyleSheet
In: rss/xml-stylesheet.rb
Parent: Object

Methods

alternate=   href=   new   setup_maker   to_s  

Included Modules

Utils

Constants

ATTRIBUTES = %w(href type title media charset alternate)
GUESS_TABLE = { "xsl" => "text/xsl", "css" => "text/css", }

Attributes

do_validate  [RW] 

Public Class methods

[Source]

# File rss/xml-stylesheet.rb, line 37
    def initialize(*attrs)
      @do_validate = true
      ATTRIBUTES.each do |attr|
        self.send("#{attr}=", nil)
      end
      vars = ATTRIBUTES.dup
      vars.unshift(:do_validate)
      attrs.each do |name, value|
        if vars.include?(name.to_s)
          self.send("#{name}=", value)
        end
      end
    end

Public Instance methods

[Source]

# File rss/xml-stylesheet.rb, line 75
    def alternate=(value)
      if value.nil? or /\A(?:yes|no)\z/ =~ value
        @alternate = value
      else
        if @do_validate
          args = ["?xml-stylesheet?", %Q[alternate="#{value}"]]
          raise NotAvailableValueError.new(*args)
        end
      end
      @alternate
    end

[Source]

# File rss/xml-stylesheet.rb, line 66
    def href=(value)
      @href = value
      if @href and @type.nil?
        @type = guess_type(@href)
      end
      @href
    end

[Source]

# File rss/xml-stylesheet.rb, line 87
    def setup_maker(maker)
      xss = maker.xml_stylesheets.new_xml_stylesheet
      ATTRIBUTES.each do |attr|
        xss.__send__("#{attr}=", __send__(attr))
      end
    end

[Source]

# File rss/xml-stylesheet.rb, line 51
    def to_s
      rv = ""
      if @href
        rv << %Q[<?xml-stylesheet]
        ATTRIBUTES.each do |name|
          if self.send(name)
            rv << %Q[ #{name}="#{h self.send(name)}"]
          end
        end
        rv << %Q[?>]
      end
      rv
    end

[Validate]