class FeedUtils::AtomV03Helper

Public Instance Methods

convert( xml ) click to toggle source
# File lib/feedutils/helper/atom_v03.rb, line 45
def convert( xml )
  xml = xml.sub( /<feed[^>]+>/ ) do |m|
    ## Note: m passed in is just a string w/ the match (NOT a match data object!)
    ## puts "match (#{m.class.name}): "
    ## pp m
    el = m.sub( /version="0\.3"/, '' )
    el = el.sub( /xmlns="http:\/\/purl\.org\/atom\/ns#"/, 'xmlns="http://www.w3.org/2005/Atom"' )
    el
  end

  xml = xml.gsub( /<modified>/, '<updated>' )
  xml = xml.gsub( /<\/modified>/, '</updated>' )

  xml = xml.gsub( /<issued>/, '<published>' )
  xml = xml.gsub( /<\/issued>/, '</published>' )
  xml
end
match?( xml ) click to toggle source
# File lib/feedutils/helper/atom_v03.rb, line 40
def match?( xml )
  ## Note: =~ return nil on match; convert to boolean e.g. always return true|false
  (xml =~ /<feed\s+version="0\.3"/) != nil
end