Class: Google::Protobuf::RepeatedField::ProxyingEnumerator

Inherits:
Struct
  • Object
show all
Defined in:
lib/google/protobuf/repeated_field.rb

Overview

propagates changes made by user of enumerator back to the original repeated field. This only applies in cases where the calling function which created the enumerator, such as #sort!, modifies itself rather than a new array, such as #sort

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#external_enumeratorObject

Returns the value of attribute external_enumerator

Returns:

  • (Object)

    the current value of external_enumerator



160
161
162
# File 'lib/google/protobuf/repeated_field.rb', line 160

def external_enumerator
  @external_enumerator
end

#repeated_fieldObject

Returns the value of attribute repeated_field

Returns:

  • (Object)

    the current value of repeated_field



160
161
162
# File 'lib/google/protobuf/repeated_field.rb', line 160

def repeated_field
  @repeated_field
end

Instance Method Details

#each(*args, &block) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/google/protobuf/repeated_field.rb', line 161

def each(*args, &block)
  results = []
  external_enumerator.each_with_index do |val, i|
    result = yield(val)
    results << result
    #nil means no change occurred from yield; usually occurs when #to_a is called
    if result
      repeated_field[i] = result if result != val
    end
  end
  results
end