Class: Protobuf::Node::ExtensionsNode

Inherits:
Base
  • Object
show all
Defined in:
lib/protobuf/compiler/nodes.rb

Instance Method Summary collapse

Methods inherited from Base

#accept_rpc_visitor, #define_in_the_file

Constructor Details

#initialize(range) ⇒ ExtensionsNode

Returns a new instance of ExtensionsNode.



283
284
285
# File 'lib/protobuf/compiler/nodes.rb', line 283

def initialize(range)
  @range = range
end

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



291
292
293
294
295
296
297
298
299
# File 'lib/protobuf/compiler/nodes.rb', line 291

def accept_descriptor_visitor(visitor)
  descriptor = Google::Protobuf::DescriptorProto::ExtensionRange.new(:start => @range.first.low)
  case @range.first.high
  when NilClass then # ignore
  when :max     then descriptor.end = 1
  else               descriptor.end = @range.first.high
  end
  visitor.extension_range_descriptor = descriptor
end

#accept_message_visitor(visitor) ⇒ Object



287
288
289
# File 'lib/protobuf/compiler/nodes.rb', line 287

def accept_message_visitor(visitor)
  visitor.write("extensions #{@range.first.to_s}")
end