Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/xml_easy.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/xml_easy.rb', line 8

def method_missing(name, *args, &block)
  if all? {|e| nil? or e.class == XmlEasy::Element}
    elms = map{|e| e.send(name, *args, &block) rescue nil}.flatten.compact
    unless block.nil?
      elms = elms.select &block
    end
    elms
  else
    raise NoMethodError.new(name)
  end
end