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.



281
282
283
# File 'lib/protobuf/compiler/nodes.rb', line 281

def initialize(range)
  @range = range
end

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



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

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

#accept_message_visitor(visitor) ⇒ Object



285
286
287
# File 'lib/protobuf/compiler/nodes.rb', line 285

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