class RBS::Annotate::Annotations::Copy

属性

annotation[R]
source[R]

公共类方法

new(annotation:, source:) 点击切换源代码
# File rbs-3.8.0/lib/rbs/annotate/annotations.rb, line 54
def initialize(annotation:, source:)
  @annotation = annotation
  @source = source
end

公共实例方法

==(other) 点击切换源代码
# File rbs-3.8.0/lib/rbs/annotate/annotations.rb, line 84
def ==(other)
  other.is_a?(Copy) &&
    other.annotation == annotation &&
    other.source == source
end
别名:eql?
eql?(other)
别名为:==
hash() 点击切换源代码
# File rbs-3.8.0/lib/rbs/annotate/annotations.rb, line 80
def hash
  self.class.hash ^ annotation.hash ^ source.hash
end
method_name() 点击切换源代码
# File rbs-3.8.0/lib/rbs/annotate/annotations.rb, line 64
def method_name
  _, m = partition
  if m
    m[1]
  end
end
partition() 点击切换源代码
# File rbs-3.8.0/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
singleton?() 点击切换源代码
# File rbs-3.8.0/lib/rbs/annotate/annotations.rb, line 71
def singleton?
  _, m = partition
  if m
    m[0]
  else
    false
  end
end
type_name() 点击切换源代码
# File rbs-3.8.0/lib/rbs/annotate/annotations.rb, line 59
def type_name
  name, _ = partition
  name
end