In Files

  • rbs-2.1.0/lib/rbs/annotate/annotations.rb

Class/Module Index [+]

Quicksearch

RBS::Annotate::Annotations::Copy

Attributes

annotation[R]
source[R]

Public Class Methods

new(annotation:, source:) click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 52
def initialize(annotation,, source))
  @annotation = annotation
  @source = source
end
            

Public Instance Methods

==(other) click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 82
def ==(other)
  other.is_a?(Copy) &&
    other.annotation == annotation &&
    other.source == source
end
            
Also aliased as: eql?
eql?(other) click to toggle source
Alias for: ==
hash() click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 78
def hash
  self.class.hash ^ annotation.hash ^ source.hash
end
            
method_name() click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 62
def method_name
  _, m = partition
  if m
    m[1]
  end
end
            
partition() click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 90
def partition
  case
  when match = source.match(/(?<constant_name>[^#]+)#(?<method_name>.+)/)
    [
      TypeName(match[:constant_name] || raise),
      [
        false,
        (match[:method_name] or raise).to_sym
      ]
    ]
  when match = source.match(/(?<constant_name>[^#]+)\.(?<method_name>.+)/)
    [
      TypeName(match[:constant_name] || raise),
      [
        true,
        (match[:method_name] or raise).to_sym
      ]
    ]
  else
    [
      TypeName(source),
      nil
    ]
  end
end
            
singleton?() click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 69
def singleton?
  _, m = partition
  if m
    m[0]
  else
    false
  end
end
            
type_name() click to toggle source
 
               # File rbs-2.1.0/lib/rbs/annotate/annotations.rb, line 57
def type_name
  name, _ = partition
  name
end
            
There is an updated format of the API docs for this version here.