Class: Tins::MethodDescription::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/tins/method_description.rb

Overview

Represents the signature of a method including all its parameters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*parameters) ⇒ Signature

Initializes a new signature with given parameters.

Parameters:



130
131
132
# File 'lib/tins/method_description.rb', line 130

def initialize(*parameters)
  @parameters = parameters
end

Instance Attribute Details

#parametersArray<Parameters::Parameter> (readonly)

Returns the parameters associated with this signature.

Returns:



137
138
139
# File 'lib/tins/method_description.rb', line 137

def parameters
  @parameters
end

Instance Method Details

#==(other) ⇒ Boolean

Checks if two signatures are equal (alias for eql?).

Parameters:

  • other (Signature)

    The other signature to compare against

Returns:

  • (Boolean)

    Whether the signatures are equal



151
152
153
# File 'lib/tins/method_description.rb', line 151

def ==(other)
  @parameters == other.parameters
end

#===(method) ⇒ Boolean

Pattern matching operator for comparing with a method’s signature.

Parameters:

  • method (Method)

    The method whose signature we’re checking

Returns:

  • (Boolean)

    Whether this signature matches the method’s signature



159
160
161
# File 'lib/tins/method_description.rb', line 159

def ===(method)
  self == method.signature
end

#eql?(other) ⇒ Boolean

Checks if two signatures are equal based on their parameters.

Parameters:

  • other (Signature)

    The other signature to compare against

Returns:

  • (Boolean)

    Whether the signatures are equal



143
144
145
# File 'lib/tins/method_description.rb', line 143

def eql?(other)
  @parameters.eql? other.parameters
end

#inspectString

Returns a detailed string representation for debugging.

Returns:

  • (String)

    A debug-friendly representation of the signature



173
174
175
# File 'lib/tins/method_description.rb', line 173

def inspect
  "#<#{self.class} (#{to_s})>"
end

#to_sString

Converts the signature to a comma-separated string.

Returns:

  • (String)

    The parameters formatted as a string



166
167
168
# File 'lib/tins/method_description.rb', line 166

def to_s
  @parameters * ?,
end