class Parlour::RbiGenerator::Include

Represents an include call.

Public Class Methods

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

Creates a new include call.

@param name [String] The name of the object to be included.

Calls superclass method
# File lib/parlour/rbi_generator/include.rb, line 16
def initialize(generator, name: '', &block)
  super(generator, name)
  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/rbi_generator/include.rb, line 27
def ==(other)
  Include === other && name == other.name
end
describe() click to toggle source

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

@return [String]

# File lib/parlour/rbi_generator/include.rb, line 82
def describe
  "Include (#{name})"
end
generalize_from_rbi!() click to toggle source
# File lib/parlour/rbi_generator/include.rb, line 87
def generalize_from_rbi!; end
generate_rbi(indent_level, options) click to toggle source

Generates the RBI 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 RBI lines, formatted as specified.

# File lib/parlour/rbi_generator/include.rb, line 42
def generate_rbi(indent_level, options)
  [options.indented(indent_level, "include #{name}")]
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<RbiGenerator::RbiObject>] An array of other

{Include} instances.

@return [void]

# File lib/parlour/rbi_generator/include.rb, line 74
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<RbiGenerator::RbiObject>] An array of other

{Include} instances.

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

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