我正在尝试构建一个shoes应用程序,但是由于某种原因,我在类实例上调用的方法(print_statement)什么也做不了。我可以看到实例已经在shoes应用程序中创建(其中的方法已准备好使用),但当我调用该方法时,似乎什么都没有发生(它在IRB中工作得很好)。
鞋码:
`flow(margin: 15) do
button "Print Statement" do
@statement = Statement.new(@account)
para @statement.print_statement
end
end`语句中的实例方法为:
def print_statement
i = 0
print_array = []
while i < account.transaction_record.length
transaction = account.transaction_record[i]
transaction_object = transaction[0]
print_array.push( "Date: #{transaction_object.created_date} " \
"Transaction Type: #{transaction_object.class} " \
"Amount: #{transaction_object.value} Balance: #{transaction[1]}" )
i += 1
end
return print_array
end对同一实例上的attr_reader方法的调用可以工作,但对print_statement方法的调用不起作用(这不是最优雅的方法!)即使在RSpec和IRB中进行了测试和工作。
发布于 2017-01-15 22:50:06
到目前为止,当我在我的项目代码中更新代码时,我会简单地关闭运行项目的Shoes窗口,重新打开它,代码更新都会在那里进行,直到这个问题发生。
当我从我的Mac dock上退出整个Shoes应用程序并重新启动它,然后在Shoes中再次打开我的项目后,它似乎已经解决了。
https://stackoverflow.com/questions/41648732
复制相似问题