Module: Protod::Proto::FieldNumeringable

Included in:
Message, Oneof
Defined in:
lib/protod/proto/part.rb

Instance Method Summary collapse

Instance Method Details

#numbering_fields_with(start_index) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/protod/proto/part.rb', line 163

def numbering_fields_with(start_index)
  index = start_index

  fields.each do |f|
    case f
    when Protod::Proto::Field
      f.index = index

      index = f.index + 1
    when Protod::Proto::Oneof
      index = f.numbering_fields_with(index)
    else
      raise NotImplementedError, "Sorry, this is bug forgetting to implement for #{f.class.name}"
    end
  end

  index
end