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



170
171
172
# File 'lib/google/protobuf/repeated_field.rb', line 170

def external_enumerator
  @external_enumerator
end

#repeated_fieldObject

Returns the value of attribute repeated_field

Returns:

  • (Object)

    the current value of repeated_field



170
171
172
# File 'lib/google/protobuf/repeated_field.rb', line 170

def repeated_field
  @repeated_field
end

Instance Method Details

#each(*args, &block) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/google/protobuf/repeated_field.rb', line 171

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