class Module
Represents a Ruby module definition wrapper for RBS generation.
Definitions
def initialize(definition)
Initialize a new module wrapper.
Signature
-
parameter
definition
Decode::Definition
The module definition to wrap.
Implementation
def initialize(definition)
super
end
def to_rbs_ast(method_definitions = [], index = nil)
Convert the module definition to RBS AST
Implementation
def to_rbs_ast(method_definitions = [], index = nil)
name = simple_name_to_rbs(@definition.name)
comment = extract_comment(@definition)
# Build method definitions
methods = method_definitions.map{|method_def| Method.new(method_def).to_rbs_ast(index)}.compact
::RBS::AST::Declarations::Module.new(
name: name,
type_params: [],
self_types: [],
members: methods,
annotations: [],
location: nil,
comment: comment
)
end
def simple_name_to_rbs(name)
Convert a simple name to RBS TypeName (not qualified)
Implementation
def simple_name_to_rbs(name)
::RBS::TypeName.new(name: name.to_sym, namespace: ::RBS::Namespace.empty)
end