Class: SimpleRSS

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-rss.rb

Constant Summary collapse

VERSION =
"2.0.0".freeze
DATE_TAGS =
%i[pubDate lastBuildDate published updated expirationDate modified dc:date].freeze
STRIP_HTML_TAGS =
%i[author contributor skipHours skipDays].freeze
@@feed_tags =
%i[
  id
  title subtitle link
  description
  author webMaster managingEditor contributor
  pubDate lastBuildDate updated dc:date
  generator language docs cloud
  ttl skipHours skipDays
  image logo icon rating
  rights copyright
  textInput feedburner:browserFriendly
  itunes:author itunes:category
]
@@item_tags =
%i[
  id
  title link link+alternate link+self link+edit link+replies
  author contributor
  description summary content content:encoded comments
  pubDate published updated expirationDate modified dc:date
  category guid
  trackback:ping trackback:about
  dc:creator dc:title dc:subject dc:rights dc:publisher
  feedburner:origLink
  media:content#url media:content#type media:content#height media:content#width media:content#duration
  media:title media:thumbnail#url media:thumbnail#height media:thumbnail#width
  media:credit media:credit#role
  media:category media:category#scheme
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ SimpleRSS

Returns a new instance of SimpleRSS.



48
49
50
51
52
53
54
55
# File 'lib/simple-rss.rb', line 48

def initialize(source, options = {})
  @source = source.respond_to?(:read) ? source.read.to_s : source.to_s
  @items = [] #: Array[Hash[Symbol, untyped]]
  @options = {} #: Hash[Symbol, untyped]
  @options.update(options)

  parse
end

Instance Attribute Details

#itemsObject (readonly) Also known as: entries

Returns the value of attribute items.



13
14
15
# File 'lib/simple-rss.rb', line 13

def items
  @items
end

#sourceObject (readonly)

: String



14
15
16
# File 'lib/simple-rss.rb', line 14

def source
  @source
end

Class Method Details

.feed_tagsObject



65
66
67
# File 'lib/simple-rss.rb', line 65

def feed_tags
  @@feed_tags
end

.feed_tags=(ft) ⇒ Object



70
71
72
# File 'lib/simple-rss.rb', line 70

def feed_tags=(ft)
  @@feed_tags = ft
end

.item_tagsObject



75
76
77
# File 'lib/simple-rss.rb', line 75

def item_tags
  @@item_tags
end

.item_tags=(it) ⇒ Object



80
81
82
# File 'lib/simple-rss.rb', line 80

def item_tags=(it)
  @@item_tags = it
end

.parse(source, options = {}) ⇒ Object

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



87
88
89
# File 'lib/simple-rss.rb', line 87

def parse(source, options = {})
  new source, options
end

Instance Method Details

#channelObject Also known as: feed



58
59
60
# File 'lib/simple-rss.rb', line 58

def channel
  self
end