def query(*arguments, &block)
      case arguments.length
      when 0
        selector, q = :all, nil
      when 1
        selector, q = :all, arguments[0]
      when 2
        selector, q = arguments
      else
        raise ArgumentError, "wrong number of arguments (#{arguments.length} for 0..2)"
      end

      filter = block ? Proc.new { |e| e.match?(q) && block.call(e) } :
        Proc.new { |e| e.match?(q) }

      send(query_handler(selector), &filter)
    end
def query(*arguments, &block)
      case arguments.length
      when 0
        selector, q = :all, nil
      when 1
        selector, q = :all, arguments[0]
      when 2
        selector, q = arguments
      else
        raise ArgumentError, "wrong number of arguments (#{arguments.length} for 0..2)"
      end

      filter = block ? Proc.new { |e| e.match?(q) && block.call(e) } :
        Proc.new { |e| e.match?(q) }

      send(query_handler(selector), &filter)
    end
call-seq:
   bib.query()          #=> returns all elements
   bib.query('@book')   #=> returns all books
   bib.query('@entry')  #=> returns all entries (books, articles etc.)
   bib.query('@*')      #=> same as above
   bib.query(:first, '@book, @article')
     #=> returns the first book or article or nil
   bib.query('@book[year<=2011], @article)
     #=> returns all books published in 2011 or earlier and all articles
   bib.query('@book, @article) { |o| o.year == '2011' }
     #=> returns all books and articles published in 2011
   bib.query('@book[year=2011], @article[year=2011])
     #=> same as above without using a block

 Returns objects in the Bibliography which match the given selector and,
 optionally, the conditions specified in the given block.

 Queries offer syntactic sugar for common enumerator invocations:

     >> bib.query(:all, '@book')
     => same as bib.select { |b| b.has_type?(:book) }
     >> bib.query('@book')
     => same as above
     >> bib.query(:first, '@book')
     => same as bib.detect { |b| b.has_type?(:book) }
     >> bib.query(:none, '@book')
     => same as bib.reject { |b| b.has_type?(:book) }