class Parlour::RbsGenerator::Block

Represents a block in a method signature. (This is not an RbsObject because it doesn't generate a full line.)

Attributes

required[R]

Whether this block is required. @return [Boolean]

type[R]

The type of this block. @return [Types::Proc]

Public Class Methods

new(type, required) click to toggle source

Creates a new block for a method signature.

@param type [Types::Proc] The type of this block. @param required [T::Boolean] Whether this block is required.

# File lib/parlour/rbs_generator/block.rb, line 14
def initialize(type, required)
  @type = type
  @required = required
end

Public Instance Methods

==(other) click to toggle source

Returns true if this instance is equal to another method signature.

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

subclass of it), this will always return false.

@return [Boolean]

# File lib/parlour/rbs_generator/block.rb, line 25
def ==(other)
  Block === other && type == other.type && required == other.required
end
generate_rbs(options) click to toggle source

Generates the RBS string for this signature.

@param options [Options] The formatting options to use. @return [Array<String>] The RBS string, formatted as specified.

# File lib/parlour/rbs_generator/block.rb, line 44
def generate_rbs(options)
  ["#{required ? '' : '?'}{ #{type.generate_rbs} }"]
end