ruby 中没有方法名称的调用

Invocation in ruby without a method name

在我的 Guardfile 中,我有这种奇怪的方法调用语法 rspec.spec.("requests/#{m[1]}")。虽然这很完美,但我不明白实际调用的是什么方法。

是否有此语法的名称或术语?

guard :rspec, cmd: "bundle exec rspec" do

  # ...
  watch(rails.controllers) do |m|
    [
      rspec.spec.("routing/#{m[1]}_routing"),
      rspec.spec.("controllers/#{m[1]}_controller"),
      rspec.spec.("requests/#{m[1]}")
    ]
  end
end

尝试:

foo = "Foo"
foo.("a")
# NoMethodError: undefined method `call' for "Foo":String

routine = Proc.new { |arg| puts "Hello #{arg}!" }
routine.("world")
# Hello world!