#
# collfrom.rb
#
#   Copyright (c) 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
#
#   This program is free software.
#   You can distribute/modify this program under the terms of
#   the GNU General Public License version 2 or later.
#


class Object

  private

  def collect_from( obj, mid, *args )
    obj ||= self

    arr = []
    i = tmp = nil
    if iterator? then
      obj.send( mid, *args ) do |i|
        tmp = yield( i )
        arr.push tmp
        tmp
      end
    else
      obj.send( mid, *args ) {|i| arr.push i }
    end

    arr
  end

end
