class Parlour::RbsGenerator::Extend

Represents an extend call.

Attributes

type[R]

@return [Types::TypeLike] The type to extend.

Public Class Methods

new(generator, type:, &block) click to toggle source

Creates a new extend call.

@param type [Types::TypeLike] The type to extend.

Calls superclass method
# File lib/parlour/rbs_generator/extend.rb, line 16
def initialize(generator, type:, &block)
  super(generator, '')
  @type = type
  yield_self(&block) if block
end

Public Instance Methods

==(other) click to toggle source

Returns true if this instance is equal to another extend.

@param other [Object] The other instance. If this is not a {Extend} (or a

subclass of it), this will always return false.

@return [Boolean]

# File lib/parlour/rbs_generator/extend.rb, line 28
def ==(other)
  Extend === other && type == other.type
end
describe() click to toggle source

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

@return [String]

# File lib/parlour/rbs_generator/extend.rb, line 87
def describe
  "Extend (#{@type})"
end
generate_rbs(indent_level, options) click to toggle source

Generates the RBS lines for this extend.

@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/extend.rb, line 47
def generate_rbs(indent_level, options)
  [options.indented(indent_level, "extend #{String === @type ? @type : @type.generate_rbs}")]
end
merge_into_self(others) click to toggle source

Given an array of {Extend} instances, merges them into this one. This particular implementation will simply do nothing, as instances are only mergeable if they are indentical. You MUST ensure that {mergeable?} is true for those instances.

@param others [Array<RbsGenerator::RbsObject>] An array of other

{Extend} instances.

@return [void]

# File lib/parlour/rbs_generator/extend.rb, line 79
def merge_into_self(others)
  # We don't need to change anything! We only merge identical extends
end
mergeable?(others) click to toggle source

Given an array of {Extend} instances, returns true if they may be merged into this instance using {merge_into_self}. This is always false.

@param others [Array<RbsGenerator::RbsObject>] An array of other

{Extend} instances.

@return [Boolean] Whether this instance may be merged with them.

# File lib/parlour/rbs_generator/extend.rb, line 62
def mergeable?(others)
  others.all? { |other| self == other }
end