Sha256: af1093d89b50013eb60464f1ebfe855ac22dfde7fd6b5b42185b332a3fe323f0

Contents?: true

Size: 793 Bytes

Versions: 3

Compression:

Stored size: 793 Bytes

Contents

=begin
  Copyright (C) 2008 Sam Roberts

  This library is free software; you can redistribute it and/or modify it
  under the same terms as the ruby language itself, see the file COPYING for
  details.
=end

module Vpim
  # This is a way for an object to have multiple ways of being enumerated via
  # argument to it's #each() method. An Enumerator mixes in Enumerable, so the
  # standard APIs such as Enumerable#map(), Enumerable#to_a(), and
  # Enumerable#find_all() can be used on it.
  #
  # TODO since 1.8, this is part of the standard library, I should rewrite vPim
  # so this can be removed.
  class Enumerator
    include Enumerable

    def initialize(obj, *args)
      @obj = obj
      @args = args
    end

    def each(&block)
      @obj.each(*@args, &block)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
qoobaa-vcard-0.1.0 lib/vcard/enumerator.rb
qoobaa-vcard-0.1.1 lib/vcard/enumerator.rb
vcard-0.1.1 lib/vcard/enumerator.rb