Method: When::Parts::Enumerator#with_object

Defined in:
lib/when_exe/parts/enumerator.rb

#with_object(object, &block) ⇒ When::Parts:Enumerator

index をブロックに渡して評価する

Parameters:

  • object (Comparable)

    ブロックに渡す Object

Returns:

  • (When::Parts:Enumerator)
    ブロックあり - rewind された self
    ブロックなし - copy


147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/when_exe/parts/enumerator.rb', line 147

def with_object(object, &block)
  if block_given?
    @object = object
    each(block)
    return object
  else
    copy = _copy
    copy.object = object
    copy.index  = nil
    return copy
  end
end