Class: FeedUtils::AtomV03Helper

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/feedutils/helper/atom_v03.rb

Instance Method Summary collapse

Instance Method Details

#convert(xml) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# 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