Class: Protobuf::Node::EnumNode

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(name, children) ⇒ EnumNode

Returns a new instance of EnumNode.



150
151
152
# File 'lib/protobuf/compiler/nodes.rb', line 150

def initialize(name, children)
  @name, @children = name, children
end

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



163
164
165
166
167
168
169
# File 'lib/protobuf/compiler/nodes.rb', line 163

def accept_descriptor_visitor(visitor)
  descriptor = Google::Protobuf::EnumDescriptorProto.new(:name => @name.to_s)
  visitor.enum_descriptor = descriptor
  visitor.in_context(descriptor) do
    @children.each {|child| child.accept_descriptor_visitor(visitor) }
  end
end

#accept_message_visitor(visitor) ⇒ Object



154
155
156
157
158
159
160
161
# File 'lib/protobuf/compiler/nodes.rb', line 154

def accept_message_visitor(visitor)
  visitor.write("class #{@name} < ::Protobuf::Enum")
  visitor.in_context(self.class) do
    define_in_the_file(visitor)
    @children.each {|child| child.accept_message_visitor(visitor) }
  end
  visitor.write('end')
end