Class: Parlour::RbsGenerator::ModuleNamespace

Inherits:
Namespace show all
Extended by:
T::Sig
Defined in:
lib/parlour/rbs_generator/module_namespace.rb

Overview

Represents a module definition.

Instance Attribute Summary

Attributes inherited from Namespace

#children

Attributes inherited from RbsObject

#generator

Attributes inherited from TypedObject

#comments, #generated_by, #name

Instance Method Summary collapse

Methods inherited from Namespace

#add_comment_to_next_child, #aliases, #constants, #create_arbitrary, #create_attr_accessor, #create_attr_reader, #create_attr_writer, #create_attribute, #create_class, #create_constant, #create_extend, #create_extends, #create_include, #create_includes, #create_interface, #create_method, #create_module, #create_type_alias, #extends, #includes, #initialize, #merge_into_self, #mergeable?, #path

Methods inherited from RbsObject

#initialize, #merge_into_self, #mergeable?

Methods inherited from TypedObject

#add_comment, #initialize

Constructor Details

This class inherits a constructor from Parlour::RbsGenerator::Namespace

Instance Method Details

#describeString

Returns a human-readable brief string description of this module.

Returns:

  • (String)


29
30
31
32
# File 'lib/parlour/rbs_generator/module_namespace.rb', line 29

def describe
  "Module #{name} - #{children.length} " +
    "children, #{includes.length} includes, #{extends.length} extends"
end

#generate_rbs(indent_level, options) ⇒ Array<String>

Generates the RBS lines for this module.

Parameters:

  • indent_level (Integer)

    The indentation level to generate the lines at.

  • options (Options)

    The formatting options to use.

Returns:

  • (Array<String>)

    The RBS lines, formatted as specified.



19
20
21
22
23
24
# File 'lib/parlour/rbs_generator/module_namespace.rb', line 19

def generate_rbs(indent_level, options)        
  lines = generate_comments(indent_level, options)
  lines << options.indented(indent_level, "module #{name}")
  lines += generate_body(indent_level + 1, options)
  lines << options.indented(indent_level, "end")
end