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

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/ast/members.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_type:, annotations:) ⇒ Overload

Returns a new instance of Overload.



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

#annotationsObject (readonly)

Returns the value of attribute annotations.



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

def annotations
  @annotations
end

#method_typeObject (readonly)

Returns the value of attribute method_type.



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

def method_type
  @method_type
end

Instance Method Details

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



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

#hashObject



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

def hash
  method_type.hash ^ annotations.hash
end

#sub(subst) ⇒ Object



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

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

#to_json(state = _ = nil) ⇒ Object



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

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

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



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