我希望根据先前声明的参数的值指定参数的默认值。在此示例中,handlerSendPort
默认值应为handlerRecvPort + 1
require "thor/group"
module Noov
class App < Thor::Group
include Thor::Actions
argument :name, type: :string, desc: "The name of the project to create"
argument :handlerRecvPort, type: :numeric, desc: "The 0MQ recv port number on the handler side (random if not specified)", optional: true, default: rand(2**16-1024)+1024+1
argument :handlerSendPort, type: :numeric, desc: "The 0MQ send port number on the handler side (recv port + 1 if not specified)", optional: true, default: handlerRecvPort+1
argument :handlerUUID, type: :string, desc: "The mongrel2 server UUID (project name if not specified)", optional: true, default: name
desc "Creates a project directory for a new website. Fully equipped to support BDD with Cucumber"
end
end
这失败了:
undefined local variable or method
Noov::App:Class (NameError) 的 handlerRecvPort'`
我意识到参数值在类评估的上下文中不可用(尽管我希望有一些超魔来使其工作),那么此时我如何访问参数值?