Class: Parlour::RbsGenerator::RbsObject Abstract

Inherits:
TypedObject show all
Defined in:
lib/parlour/rbs_generator/rbs_object.rb

Overview

This class is abstract.

An abstract class which is subclassed by any classes which can generate entire lines of an RBS, such as Namespace and Method. (As an example, Parameter is not a subclass because it does not generate lines, only segments of definition lines.)

Direct Known Subclasses

Arbitrary, Constant, Extend, Include, Method, Namespace, TypeAlias

Instance Attribute Summary collapse

Attributes inherited from TypedObject

#comments, #generated_by, #name

Instance Method Summary collapse

Methods inherited from TypedObject

#add_comment, #describe, #describe_tree

Constructor Details

#initialize(generator, name) ⇒ void

Note:

Don’t call this directly.

Creates a new RBS object.

Parameters:

  • generator (RbsGenerator)

    The current RbsGenerator.

  • name (String)

    The name of this module.



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

def initialize(generator, name)
  super(name)
  @generator = generator
  @generated_by = RbsGenerator === generator ? generator.current_plugin : nil
end

Instance Attribute Details

#generatorGenerator (readonly)

The generator which this object belongs to.

Returns:



28
29
30
# File 'lib/parlour/rbs_generator/rbs_object.rb', line 28

def generator
  @generator
end

Instance Method Details

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

This method is abstract.

Generates the RBS lines for this object.

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.



42
# File 'lib/parlour/rbs_generator/rbs_object.rb', line 42

def generate_rbs(indent_level, options); end

#merge_into_self(others) ⇒ void

This method is abstract.

This method returns an undefined value.

Given an array of other objects, merges them into this one. Each subclass will do this differently. You MUST ensure that #mergeable? is true for those instances.

Parameters:



70
# File 'lib/parlour/rbs_generator/rbs_object.rb', line 70

def merge_into_self(others); end

#mergeable?(others) ⇒ Boolean

This method is abstract.

Given an array of other objects, returns true if they may be merged into this instance using #merge_into_self. Each subclass will have its own criteria on what allows objects to be mergeable.

Parameters:

Returns:

  • (Boolean)

    Whether this instance may be merged with them.



56
# File 'lib/parlour/rbs_generator/rbs_object.rb', line 56

def mergeable?(others); end