Class: Fede::XMLFeed

Inherits:
Object
  • Object
show all
Defined in:
lib/fede/xml_feed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes = []) ⇒ XMLFeed

Returns a new instance of XMLFeed.



5
6
7
# File 'lib/fede/xml_feed.rb', line 5

def initialize(nodes = [])
  @nodes = nodes
end

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes.



3
4
5
# File 'lib/fede/xml_feed.rb', line 3

def nodes
  @nodes
end

Instance Method Details



15
16
17
# File 'lib/fede/xml_feed.rb', line 15

def footer
  "</rss>\n"
end

#headerObject



9
10
11
12
13
# File 'lib/fede/xml_feed.rb', line 9

def header
  "<?xml version='1.0' encoding='UTF-8'?>\n<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'"\
  " xmlns:cc='http://web.resource.org/cc/' xmlns:itunes='http://www.itunes.com/dtds/podcast-1.0.dtd'"\
  " xmlns:media='http://search.yahoo.com/mrss/' xmlns:content='http://purl.org/rss/1.0/modules/content/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n"
end

#to_sObject



19
20
21
22
23
24
25
26
27
# File 'lib/fede/xml_feed.rb', line 19

def to_s
  '' unless @nodes

  nodes_string = @nodes.reduce('') do |prev, node|
    "#{prev}#{node.to_s(1)}"
  end

  "#{header}#{nodes_string}#{footer}"
end