class SyntaxTree::ModuleDeclaration
ModuleDeclaration
represents defining a module using the module
keyword.
module Namespace end
Attributes
bodystmt[R]
BodyStmt
-
the expressions to be executed in the context of the module
constant[R]
ConstPathRef
|ConstRef
|TopConstRef
-
the name of the module
Public Class Methods
new(constant:, bodystmt:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 7789 def initialize(constant:, bodystmt:, location:) @constant = constant @bodystmt = bodystmt @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 7849 def ===(other) other.is_a?(ModuleDeclaration) && constant === other.constant && bodystmt === other.bodystmt end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 7796 def accept(visitor) visitor.visit_module(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 7800 def child_nodes [constant, bodystmt] end
Also aliased as: deconstruct
copy(constant: nil, bodystmt: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 7804 def copy(constant: nil, bodystmt: nil, location: nil) node = ModuleDeclaration.new( constant: constant || self.constant, bodystmt: bodystmt || self.bodystmt, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 7818 def deconstruct_keys(_keys) { constant: constant, bodystmt: bodystmt, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 7827 def format(q) if bodystmt.empty? q.group do format_declaration(q) q.breakable_force q.text("end") end else q.group do format_declaration(q) q.indent do q.breakable_force q.format(bodystmt) end q.breakable_force q.text("end") end end end