Class: RBS::AST::Members::MethodDefinition::Overload

Inherits:
Object
  • Object
show all
Includes:
_ToJson
Defined in:
lib/rbs/ast/members.rb,
sig/members.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_type:, annotations:) ⇒ Overload

Returns a new instance of Overload.

Parameters:



13
14
15
16
# File 'lib/rbs/ast/members.rb', line 13

def initialize(method_type:, annotations:)
  @method_type = method_type
  @annotations = annotations
end

Instance Attribute Details

#annotationsArray[Annotation] (readonly)

Returns the value of attribute annotations.

Returns:



11
12
13
# File 'lib/rbs/ast/members.rb', line 11

def annotations
  @annotations
end

#method_typeMethodType (readonly)

Returns the value of attribute method_type.

Returns:



11
12
13
# File 'lib/rbs/ast/members.rb', line 11

def method_type
  @method_type
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Parameters:

  • (Object)

Returns:

  • (Boolean)


18
19
20
# File 'lib/rbs/ast/members.rb', line 18

def ==(other)
  other.is_a?(Overload) && other.method_type == method_type && other.annotations == annotations
end

#hashInteger

Returns:

  • (Integer)


22
23
24
# File 'lib/rbs/ast/members.rb', line 22

def hash
  method_type.hash ^ annotations.hash
end

#sub(subst) ⇒ Overload

Parameters:

Returns:



32
33
34
35
36
# File 'lib/rbs/ast/members.rb', line 32

def sub(subst)
  return self if subst.empty?

  update(method_type: self.method_type.sub(subst))
end

#to_json(state = nil) ⇒ Object



38
39
40
41
42
43
# File 'lib/rbs/ast/members.rb', line 38

def to_json(state = nil)
  {
    annotations: annotations,
    method_type: method_type
  }.to_json(state)
end

#update(annotations: self.annotations, method_type: self.method_type) ⇒ Overload

Parameters:

  • annotations: (Array[Annotation]) (defaults to: self.annotations)
  • method_type: (MethodType) (defaults to: self.method_type)

Returns:



28
29
30
# File 'lib/rbs/ast/members.rb', line 28

def update(annotations: self.annotations, method_type: self.method_type)
  Overload.new(annotations: annotations, method_type: method_type)
end