【问题标题】:Ruby Syntax BlatherRuby 语法废话
【发布时间】:2014-05-23 17:18:05
【问题描述】:

我正在看这个例子

require 'blather/client/dsl'

module App
  extend Blather::DSL

  def self.run
    EM.run { client.run }
  end

  setup 'echo@jabber.local', 'echo'

  # Auto approve subscription requests
  subscription :request? do |s|
    write_to_stream s.approve!
  end

  # Echo back what was said
  message :chat?, :body do |m|
    write_to_stream m.reply
  end
end

trap(:INT) { EM.stop }
trap(:TERM) { EM.stop }

App.run

我了解此代码中的所有内容,但 EM 除外。参考。例如,在 self.run 中 EM.run 指的是什么?它似乎需要一个障碍,但我找不到任何关于 EM 是什么的参考。

我知道代码的作用,但我找不到任何文档,或者这是否是 ruby​​ 功能/废话功能。

【问题讨论】:

  • 看起来确实是这样。万分感谢。您是否能够在 blather 文档中找到它作为依赖项或其他内容?
  • 那么,答案告诉你这个?这是我的较长版本。
  • 如果是 gem,请检查 Rubygems.org 的依赖关系:rubygems.org/gems/blather

标签: ruby syntax xmpp


【解决方案1】:

EM 是一个类。我假设它代表 EventMachine,因为 blather 使用它,但我对此不是 100% 确定。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2022-12-03
  • 1970-01-01
  • 1970-01-01
  • 2012-11-09
  • 2017-01-02
  • 2018-08-23
  • 2017-02-01
  • 2012-02-28
相关资源
最近更新 更多