Class: Protobuf::Node::MessageNode

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) ⇒ MessageNode

Returns a new instance of MessageNode.



105
106
107
# File 'lib/protobuf/compiler/nodes.rb', line 105

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

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/protobuf/compiler/nodes.rb', line 118

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

#accept_message_visitor(visitor) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/protobuf/compiler/nodes.rb', line 109

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