Class: VkCozy::BotLabeler
- Inherits:
-
Object
- Object
- VkCozy::BotLabeler
- Defined in:
- lib/vk_cozy/framework/labeler/bot.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
- #filter(event) ⇒ Object
-
#initialize(api) ⇒ BotLabeler
constructor
A new instance of BotLabeler.
- #message_handler(filter, func) ⇒ Object
Constructor Details
#initialize(api) ⇒ BotLabeler
Returns a new instance of BotLabeler.
5 6 7 8 |
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 5 def initialize(api) @api = api @rules = [] end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
3 4 5 |
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 3 def api @api end |
Instance Method Details
#filter(event) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 10 def filter(event) for i in @rules f = i[:filter] check = f.check_bot(event) if check if check.is_a?(Symbol) check = [Symbol] elsif check.is_a?(Array) i[:func].call(event, *check) elsif check.is_a?(Hash) i[:func].call(event, **check) else i[:func].call(event) end return true end end end |
#message_handler(filter, func) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/vk_cozy/framework/labeler/bot.rb', line 29 def (filter, func) if func.is_a?(Symbol) func = method(func) end @rules << { :func => func, :filter => filter } end |