Sample Document¶
Ruby API¶
Ruby API is similar to Python API. I this section show samples in Ruby. If you need detail information see Python API reference.
Decorators¶
berryMQ provides module methods :meth:`Follower.following` and :meth:`Follower.auto_twitter`. They works like Class.public
and Class.private
and so on. It emurates decorator mechanism in Python.
Use this like following:
require 'berrymq'
class Logger
include BerryMQ::Follower
following("*:log")
def receive_log(message)
...
end
end
Class.public
keeps effect until other module method will be called,
But this functions effect only the next method definition.
Warning
Ruby implementation uses module including mechanism to class. So you can’t set module function receiver like Python.
If you want to use the method as receiver, set this class as metaclass.
This class provide special decorators. :func:`following` and :func:`auto_twitter`. Use like this:
# Ruby
class Logger
include BerryMQ::Follower
following("*:log")
def receive_log(message)
...
end
end
Functions¶
You can use :func:`BerryMQ.twitter` function like this:
require 'berrymq'
def on_button_pressed
BerryMQ.twitter("on_button_pressed:log")
.
.
end
Note
In future release, if last paramter is Hash
, it will pass as kwargs.