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-1.0.2 lib/steep/method_name.rb
steep-1.0.1 lib/steep/method_name.rb
steep-1.0.0 lib/steep/method_name.rb
steep-0.52.2 lib/steep/method_name.rb
steep-0.52.1 lib/steep/method_name.rb
steep-0.52.0 lib/steep/method_name.rb
steep-0.51.0 lib/steep/method_name.rb
steep-0.50.0 lib/steep/method_name.rb
steep-0.49.1 lib/steep/method_name.rb
steep-0.49.0 lib/steep/method_name.rb
steep-0.48.0 lib/steep/method_name.rb
steep-0.47.1 lib/steep/method_name.rb
steep-0.47.0 lib/steep/method_name.rb
steep-0.46.0 lib/steep/method_name.rb
steep-0.45.0 lib/steep/method_name.rb
steep-0.44.1 lib/steep/method_name.rb
steep-0.44.0 lib/steep/method_name.rb
steep-0.43.1 lib/steep/method_name.rb
steep-0.43.0 lib/steep/method_name.rb
steep-0.42.0 lib/steep/method_name.rb