Sha256: 2b4c778b84f5ad7f51c0276c3d9497040c9c0419ce691379b03a41a675f613a5

Contents?: true

Size: 791 Bytes

Versions: 9

Compression:

Stored size: 791 Bytes

Contents

# 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
# VPIM-LICENSE.txt for details.

module Vcard
  # 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

9 entries across 9 versions & 1 rubygems

Version Path
vcard-0.2.9 lib/vcard/enumerator.rb
vcard-0.2.8 lib/vcard/enumerator.rb
vcard-0.2.7 lib/vcard/enumerator.rb
vcard-0.2.6 lib/vcard/enumerator.rb
vcard-0.2.5 lib/vcard/enumerator.rb
vcard-0.2.4 lib/vcard/enumerator.rb
vcard-0.2.3 lib/vcard/enumerator.rb
vcard-0.2.2 lib/vcard/enumerator.rb
vcard-0.2.1 lib/vcard/enumerator.rb