class SimpleRSS

Constants

VERSION

Attributes

entries[R]
items[R]
source[R]

Public Class Methods

new(source, options={}) click to toggle source
# File lib/simple-rss.rb, line 40
    def initialize(source, options={})
            @source = source.respond_to?(:read) ? source.read : source.to_s
            @items = Array.new
@options = Hash.new.update(options)

            parse
    end

Public Instance Methods

channel() click to toggle source
# File lib/simple-rss.rb, line 48
def channel() self end
Also aliased as: feed
feed()
Alias for: channel
feed_tags() click to toggle source
# File lib/simple-rss.rb, line 52
def feed_tags
        @@feed_tags
end
feed_tags=(ft) click to toggle source
# File lib/simple-rss.rb, line 55
def feed_tags=(ft)
        @@feed_tags = ft
end
item_tags() click to toggle source
# File lib/simple-rss.rb, line 59
def item_tags
        @@item_tags
end
item_tags=(it) click to toggle source
# File lib/simple-rss.rb, line 62
def item_tags=(it)
        @@item_tags = it
end
parse(source, options={}) click to toggle source

The strict attribute is for compatibility with Ruby's standard RSS parser

# File lib/simple-rss.rb, line 67
def parse(source, options={})
        new source, options
end

Private Instance Methods

clean_content(tag, attrs, content) click to toggle source
# File lib/simple-rss.rb, line 138
def clean_content(tag, attrs, content)
        content = content.to_s
        case tag
                when :pubDate, :lastBuildDate, :published, :updated, :expirationDate, :modified, :'dc:date'
                        Time.parse(content) rescue unescape(content)
                when :author, :contributor, :skipHours, :skipDays
                        unescape(content.gsub(/<.*?>/,''))
                else
                        content.empty? && "#{attrs} " =~ /href=['"]?([^'"]*)['" ]/mi ? $1.strip : unescape(content)
        end
end
clean_tag(tag) click to toggle source
# File lib/simple-rss.rb, line 150
def clean_tag(tag)
        tag.to_s.gsub(':','_').intern
end
unescape(content) click to toggle source
# File lib/simple-rss.rb, line 154
def unescape(content)
      if content =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/n then
              CGI.unescape(content).gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
      else
              content.gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
      end
end