Method: RBS::MethodType#to_s

Defined in:
lib/rbs/method_type.rb

#to_sObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/rbs/method_type.rb', line 100

def to_s
  block_self_binding = Types::SelfTypeBindingHelper.self_type_binding_to_s(block&.self_type)

  s = case
      when (b = block) && b.required
        "(#{type.param_to_s}) { (#{b.type.param_to_s}) #{block_self_binding}-> #{b.type.return_to_s} } -> #{type.return_to_s}"
      when b = block
        "(#{type.param_to_s}) ?{ (#{b.type.param_to_s}) #{block_self_binding}-> #{b.type.return_to_s} } -> #{type.return_to_s}"
      else
        "(#{type.param_to_s}) -> #{type.return_to_s}"
      end

  if type_params.empty?
    s
  else
    "[#{type_params.join(", ")}] #{s}"
  end
end