class RBS::Definition::Method::TypeDef
Attributes
annotations
[R]
Array[AST::Annotation]
Always returns an empty array
member
[R]
method_member
member_annotations
[R]
Array[AST::Annotation]
Annotations given to the method definition syntax
If the method have multiple syntaxes, union of the annotations to the member will be included, without dedup.
The value should be updated during setup.
overload_annotations
[R]
Array[AST::Annotation]
Annotations given to the overload associated to the method type
The value should be updated during setup.
Public Class Methods
(type: MethodType, member: method_member, defined_in: TypeName, implemented_in: TypeName?) → void
(type: MethodType, member: method_member, defined_in: TypeName, implemented_in: TypeName?, overload_annotations: nil) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 40 def initialize(type:, member:, defined_in:, implemented_in:, overload_annotations: []) @type = type @member = member @defined_in = defined_in @implemented_in = implemented_in @member_annotations = [] @overload_annotations = [] @annotations = [] end
overload_annotations is ignored.
Public Instance Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 50 def ==(other) other.is_a?(TypeDef) && other.type == type && other.member == member && other.defined_in == defined_in && other.implemented_in == implemented_in end
Also aliased as: eql?
() → AST::Comment?
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 64 def comment case member when AST::Members::Base member.comment when AST::Ruby::Members::Base member.leading_comment&.as_comment end end
() { (AST::Annotation) → void } → void
() → Enumerator[AST::Annotation]
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 89 def each_annotation(&block) if block member_annotations.each(&block) overload_annotations.each(&block) else enum_for :each_annotation end end
Yields member and overload annotations, without dedup
Member annotation yields first.
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 60 def hash self.class.hash ^ type.hash ^ member.hash ^ defined_in.hash ^ implemented_in.hash end
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 80 def overload? case mem = member when AST::Members::MethodDefinition mem.overloading? else false end end
(?type: MethodType, ?member: method_member, ?defined_in: TypeName, ?implemented_in: TypeName?) → TypeDef
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/definition.rb, line 73 def update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in) TypeDef.new(type: type, member: member, defined_in: defined_in, implemented_in: implemented_in).tap do |type_def| type_def.overload_annotations.replace(self.overload_annotations) type_def.member_annotations.replace(self.member_annotations) end end