Class: RDFObject::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf_objects/pho/rdf_resource.rb

Instance Method Summary collapse

Instance Method Details

#to_rssObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/rdf_objects/pho/rdf_resource.rb', line 71

def to_rss
  uuid = ::UUID.generate
  uri = "info:uuid/#{uuid}"
  namespaces = {}
  rdf_data = ""    
  self.values.each do |item|
    ns, rss_data = item.rss_item_block
    namespaces.merge!(ns)
    rdf_data << rss_data      
  end

  unless namespaces["xmlns:rdf"]
    if  x = namespaces.index("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
      namespaces.delete(x)
    end
    namespaces["xmlns:rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  end
  namespaces["xmlns"] = "http://purl.org/rss/1.0/"
  rdf = "<rdf:RDF"
  namespaces.each_pair {|key, value| rdf << " #{key}=\"#{value}\""}
  rdf <<">"
  rdf << "<channel rdf:about=\"#{uri}\"><title>RDFObject Collection</title><link>#{uri}</link>"
  rdf << "<description>RDFOject Collection</description><items><rdf:Seq>"
  self.keys.each do |uri|
    rdf << "<rdf:li resource=\"#{uri}\" />"
  end
  rdf << "</rdf:Seq></items>"
  rdf << "</channel>"
  
    
  rdf << rdf_data
  rdf << "</rdf:RDF>"
  rdf      
end