class Parlour::RbsGenerator::RbsObject

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.) @abstract

Attributes

generator[R]

The generator which this object belongs to. @return [Generator]

Public Class Methods

new(generator, name) click to toggle source

Creates a new RBS object. @note Don't call this directly.

@param generator [RbsGenerator] The current RbsGenerator. @param name [String] The name of this module. @return [void]

Calls superclass method
# 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

Public Instance Methods

describe() click to toggle source
# File lib/parlour/rbs_generator/rbs_object.rb, line 73
def describe
  'RBS object'
end
generate_rbs(indent_level, options) click to toggle source

Generates the RBS lines for this object.

@abstract @param indent_level [Integer] The indentation level to generate the lines at. @param options [Options] The formatting options to use. @return [Array<String>] The RBS lines, formatted as specified.

# File lib/parlour/rbs_generator/rbs_object.rb, line 42
def generate_rbs(indent_level, options); end
merge_into_self(others) click to toggle source

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.

@abstract @param others [Array<RbsGenerator::RbsObject>] An array of other {RbsObject} instances. @return [void]

# File lib/parlour/rbs_generator/rbs_object.rb, line 70
def merge_into_self(others); end
mergeable?(others) click to toggle source

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.

@abstract @param others [Array<RbsGenerator::RbsObject>] An array of other {RbsObject} instances. @return [Boolean] Whether this instance may be merged with them.

# File lib/parlour/rbs_generator/rbs_object.rb, line 56
def mergeable?(others); end