Class: VkLongpollBot::Events::EventListener

Inherits:
Object
  • Object
show all
Defined in:
lib/vk_longpoll_bot/events.rb

Overview

Class containing block to run on some event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) {|event| ... } ⇒ EventListener

Initialize new listener

Parameters:

  • options (Hash)

Options Hash (options):

  • subtype (String)

Yield Parameters:



96
97
98
99
# File 'lib/vk_longpoll_bot/events.rb', line 96

def initialize(options, &block)
  @subtype = options[:subtype]
  @block = block
end

Instance Attribute Details

#subtypeString (readonly)

Returns subtype of this listener.

Returns:

  • (String)

    subtype of this listener.



86
87
88
# File 'lib/vk_longpoll_bot/events.rb', line 86

def subtype
  @subtype
end

Instance Method Details

#call(event) ⇒ void

This method returns an undefined value.

Calls block with given event as argument.

Parameters:



107
108
109
# File 'lib/vk_longpoll_bot/events.rb', line 107

def call(event)
  @block.call(event)
end