class Parlour::RbsGenerator::Include

Represents an include call.

Attributes

type[R]

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

Public Class Methods

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

Creates a new include call.

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

Calls superclass method
# File lib/parlour/rbs_generator/include.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 include.

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

subclass of it), this will always return false.

@return [Boolean]

# File lib/parlour/rbs_generator/include.rb, line 28
def ==(other)
  Include === 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/include.rb, line 87
def describe
  "Include (#{@type})"
end
generate_rbs(indent_level, options) click to toggle source

Generates the RBS lines for this include.

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

Given an array of {Include} 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

{Include} instances.

@return [void]

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

Given an array of {Include} 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

{Include} instances.

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

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