Module RSS::ListenerMixin
In: rss/parser.rb
rss/1.0.rb
rss/0.9.rb

Methods

instruction   new   tag_end   tag_start   text   xmldecl  

Constants

CONTENT_PATTERN = /\s*([^=]+)=(["'])([^\2]+?)\2/
NAMESPLIT = /^(?:([\w:][-\w\d.]*):)?([\w:][-\w\d.]*)/

Attributes

do_validate  [RW] 
ignore_unknown_element  [RW] 
rss  [R] 

Public Class methods

[Source]

# File rss/parser.rb, line 245
    def initialize
      @rss = nil
      @ignore_unknown_element = true
      @do_validate = true
      @ns_stack = [{}]
      @tag_stack = [[]]
      @text_stack = ['']
      @proc_stack = []
      @last_element = nil
      @version = @encoding = @standalone = nil
      @xml_stylesheets = []
    end

Public Instance methods

[Source]

# File rss/parser.rb, line 262
    def instruction(name, content)
      if name == "xml-stylesheet"
        params = parse_pi_content(content)
        if params.has_key?("href")
          @xml_stylesheets << XMLStyleSheet.new(*params)
        end
      end
    end

[Source]

# File rss/parser.rb, line 295
    def tag_end(name)
      if DEBUG
        p "end tag #{name}"
        p @tag_stack
      end
      text = @text_stack.pop
      tags = @tag_stack.pop
      pr = @proc_stack.pop
      pr.call(text, tags) unless pr.nil?
      @ns_stack.pop
    end

[Source]

# File rss/parser.rb, line 271
    def tag_start(name, attributes)
      @text_stack.push('')

      ns = @ns_stack.last.dup
      attrs = {}
      attributes.each do |n, v|
        if /\Axmlns(?:\z|:)/ =~ n
          ns[$POSTMATCH] = v
        else
          attrs[n] = v
        end
      end
      @ns_stack.push(ns)

      prefix, local = split_name(name)
      @tag_stack.last.push([ns[prefix], local])
      @tag_stack.push([])
      if respond_to?("start_#{local}", true)
        send("start_#{local}", local, prefix, attrs, ns.dup)
      else
        start_else_element(local, prefix, attrs, ns.dup)
      end
    end

[Source]

# File rss/parser.rb, line 307
    def text(data)
      @text_stack.last << data
    end

[Source]

# File rss/parser.rb, line 258
    def xmldecl(version, encoding, standalone)
      @version, @encoding, @standalone = version, encoding, standalone
    end

[Validate]