Sha256: 2f8fb0624f9825378cecd36353a1c4f2aaa5f2e0b29d67cc80eace176cef7348

Contents?: true

Size: 793 Bytes

Versions: 28

Compression:

Stored size: 793 Bytes

Contents

module Steep
  InstanceMethodName = Struct.new(:type_name, :method_name, keyword_init: true) do
    def to_s
      "#{type_name}##{method_name}"
    end
  end

  SingletonMethodName = Struct.new(:type_name, :method_name, keyword_init: true) do
    def to_s
      "#{type_name}.#{method_name}"
    end
  end

  module ::Kernel
    def MethodName(string)
      case string
      when /#/
        type_name, method_name = string.split(/#/, 2)
        InstanceMethodName.new(type_name: TypeName(type_name), method_name: method_name.to_sym)
      when /\./
        type_name, method_name = string.split(/\./, 2)
        SingletonMethodName.new(type_name: TypeName(type_name), method_name: method_name.to_sym)
      else
        raise "Unexpected method name: #{string}"
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
steep-0.41.0 lib/steep/method_name.rb
steep-0.40.0 lib/steep/method_name.rb
steep-0.39.0 lib/steep/method_name.rb
steep-0.38.0 lib/steep/method_name.rb
steep-0.37.0 lib/steep/method_name.rb
steep-0.36.0 lib/steep/method_name.rb
steep-0.35.0 lib/steep/method_name.rb
steep-0.34.0 lib/steep/method_name.rb