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.



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

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

Instance Method Details

#accept_descriptor_visitor(visitor) ⇒ Object



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

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

#accept_message_visitor(visitor) ⇒ Object



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

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