class RBS::Annotate::Annotations::Copy
Copy annotation allows copying the doc from another subject. This helps working with incorrect RDoc annotations.
%a{annotate:rdoc:copy:Bar#baz}
%a{annotate:rdoc:copy:Bar.baz}
%a{annotate:rdoc:copy:Bar::Baz}
Attributes
annotation
[R]
AST::Annotation
Public Class Methods
(annotation: AST::Annotation, source: String) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 54 def initialize(annotation:, source:) @annotation = annotation @source = source end
Public Instance Methods
(untyped) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 84 def ==(other) other.is_a?(Copy) && other.annotation == annotation && other.source == source end
Also aliased as: eql?, eql?
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 80 def hash self.class.hash ^ annotation.hash ^ source.hash end
() → Symbol?
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 64 def method_name _, m = partition if m m[1] end end
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 92 def partition case when match = source.match(/(?<constant_name>[^#]+)#(?<method_name>.+)/) [ TypeName.parse(match[:constant_name] || raise), [ false, (match[:method_name] or raise).to_sym ] ] when match = source.match(/(?<constant_name>[^#]+)\.(?<method_name>.+)/) [ TypeName.parse(match[:constant_name] || raise), [ true, (match[:method_name] or raise).to_sym ] ] else [ TypeName.parse(source), nil ] end end
Returns a tuple of:
-
Type name
-
A pair of:
-
Boolean which holds if it is singleton
-
Name of method
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 71 def singleton? _, m = partition if m m[0] else false end end
() → TypeName
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/lib/rbs/annotate/annotations.rb, line 59 def type_name name, _ = partition name end