rb-appscript:访问父引用?
有没有一种简单的方法可以找到引用的父元素引用?
例如,假设我有以下参考:
ref = app("System Events").processes["Safari"].windows[1].buttons[1]
我想做类似以下的事情:
ref.parent # => app("System Events").processes["Safari"].windows[1].buttons
甚至:
ref.parent # => app("System Events").processes["Safari"].windows[1]
我已经查看了文档和指南,但没有成功。我还尝试了一个大禁忌,即对 Appscript::Reference 类进行猴子修补并添加我自己的方法,但它开始以难以排除故障的方式破坏我的规范。我也考虑过使用 eval 但这似乎是一个更糟糕的主意。有什么想法吗?
Is there an easy way to find the parent element reference of a reference?
For example, suppose I have the following reference:
ref = app("System Events").processes["Safari"].windows[1].buttons[1]
I would like to do something similar to the following:
ref.parent # => app("System Events").processes["Safari"].windows[1].buttons
Or even:
ref.parent # => app("System Events").processes["Safari"].windows[1]
I've looked over the documentation and guides and haven't been successful. I also tried a big no-no by monkey-patching the Appscript::Reference class and adding my own methods but it starts to break my specs in ways that are difficult to troubleshoot. I also thought about using eval but that seemed like a worse idea. Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番挠头之后,我想我可能有一个解决方案:
Returns
是那种东西吗?
伊恩
After a bit of chin scratching, I think I might have a solution:
Returns
Is that the kind of thing?
Ian