class Post_id_rss
Attributes
idurl[R]
Public Class Methods
new(postxml)
click to toggle source
# File lib/abelard/postxml.rb, line 26 def initialize(postxml) #XmlUtil::child_content(postxml, "post_id") || @idurl = XmlUtil::child_content(postxml, "guid") @raw = postxml.to_s end
Public Instance Methods
as_comment(commentnumber)
click to toggle source
# File lib/abelard/postxml.rb, line 59 def as_comment(commentnumber) "comment-#{post_match}-#{commentnumber}.xml" end
improvise()
click to toggle source
# File lib/abelard/postxml.rb, line 76 def improvise "post-%016x.xml" % @raw.hash end
post_match()
click to toggle source
# File lib/abelard/postxml.rb, line 50 def post_match posturl = /\?p(age_id)?=(\d+)(\.xml)?$/.match(idurl) if posturl posturl[2] else sanitize end end
sanitize()
click to toggle source
# File lib/abelard/postxml.rb, line 63 def sanitize uri = URI(idurl) $stderr.puts("Could not parse url #{idurl}") unless ( uri ) if ( uri.scheme == "tag" ) return idurl.split('-').last end build = uri.path.sub(/^\//,'').sub(/\.xml$/,'').gsub('/','-') build.concat('-' + uri.query.gsub(/[?&]/,'-')) if uri.query build.concat('-' + uri.fragment) if uri.fragment build end
to_s()
click to toggle source
# File lib/abelard/postxml.rb, line 32 def to_s if !idurl improvise else postnumber = post_match commenturl = /\?p(age_id)?=(\d+)(\.xml)?#comment-(.*)$/.match(idurl) || /^(.*)\/(\d{4}\/.*)\/#(comment)-(.*)$/.match(idurl) if commenturl postnumber = commenturl[2].sub(/^\//,'').sub(/\.xml$/,'').gsub('/','-') commentnumber = commenturl[4] "comment-#{postnumber}-#{commentnumber}.xml" else "post-#{postnumber}.xml" end end end