Class: Protobuf::Node::ExtendNode

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

Returns a new instance of ExtendNode.



130
131
132
# File 'lib/protobuf/compiler/nodes.rb', line 130

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

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



144
145
146
# File 'lib/protobuf/compiler/nodes.rb', line 144

def accept_descriptor_visitor(visitor)
  # TODO: how should i handle this?
end

#accept_message_visitor(visitor) ⇒ Object



134
135
136
137
138
139
140
141
142
# File 'lib/protobuf/compiler/nodes.rb', line 134

def accept_message_visitor(visitor)
  name = @name.is_a?(Array) ? @name.join : name.to_s
  visitor.write("class #{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