Method: Atom::Parsers#on_parse

Defined in:
lib/atom/element.rb

#on_parse(name_pair, &block) ⇒ Object

adds a parser that calls the given block for a single element that matches the given name and namespace (if it exists)



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/atom/element.rb', line 65

def on_parse name_pair, &block
  uri, name = name_pair
  @on_parse ||= []

  process = lambda do |e,x|
    el = e.get_elem(x, uri, name)

    if el
      block.call e, el

      e.extensions.delete_if do |c|
        c.namespace == uri and c.name == name.to_s
      end
    end
  end

  @on_parse << process
end