Class: Archives::RSS

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

Overview

contains RSS type return and converts XML format to Ruby format

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc_root) ⇒ RSS

creates RSS class object from libxml node input



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/archives/rss.rb', line 10

def initialize(doc_root)
  channel = doc_root.find("//rss/channel").first
			%w[title total].each do |f|
RSS.class_eval("attr_accessor :#{f}")
self.instance_variable_set("@#{f}", channel.find(f).first.content)
			end

			@items = []
			channel.find("item").each do |i|
@items << Item.new(i)
			end
end

Instance Attribute Details

#itemsObject

variable for accessing items



7
8
9
# File 'lib/archives/rss.rb', line 7

def items
  @items
end