Class: Daum::RSS

Inherits:
Object
  • Object
show all
Defined in:
lib/daum/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, target) ⇒ RSS

creates RSS class object from libxml node input



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/daum/rss.rb', line 10

def initialize(doc_root, target)
			if DIFF_DOC_ROOT_LIST.include?(target.to_s)
channel = doc_root
			else
channel = doc_root.find("channel").first
			end
			
			if cs = channel.children
cs.each do |c|
	next if c.name == "item"
	RSS.class_eval("attr_accessor :#{c.name}")
	self.instance_variable_set("@#{c.name}", c.content)
end
			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/daum/rss.rb', line 7

def items
  @items
end