Class: MatrixQQ::QQ::DBus
- Inherits:
-
Object
- Object
- MatrixQQ::QQ::DBus
- Defined in:
- lib/matrix_qq/qq/dbus.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
-
#initialize(dbus) ⇒ DBus
constructor
A new instance of DBus.
- #method_missing(name, *args) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(dbus) ⇒ DBus
Returns a new instance of DBus.
6 7 8 9 10 |
# File 'lib/matrix_qq/qq/dbus.rb', line 6 def initialize(dbus) srv = dbus.service('org.dastudio.qq') @obj = srv.object '/org/dastudio/qq' @obj.default_iface = 'org.dastudio.cqhttp' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/matrix_qq/qq/dbus.rb', line 16 def method_missing(name, *args) super if args.size > 1 args << {} if args.empty? arg = args.first JSON.parse @obj.call(name.to_s, arg.to_json).first end |
Instance Attribute Details
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
4 5 6 |
# File 'lib/matrix_qq/qq/dbus.rb', line 4 def obj @obj end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
12 13 14 |
# File 'lib/matrix_qq/qq/dbus.rb', line 12 def respond_to_missing?(name, include_private = false) @obj.respond_to_missing? name, include_private end |