Class: VkLongpollBot::Events::Event

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

Overview

Class containing data recieved from longpoll. Provides easy update to it’s data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subtype, data, group_id, bot) ⇒ Event

Initialize from fields of update json and bot which got this event.



32
33
34
35
36
37
# File 'lib/vk_longpoll_bot/events.rb', line 32

def initialize(subtype, data, group_id, bot)
  @subtype = subtype.to_s
  @data = data
  @group_id = group_id.to_i
  @bot = bot
end

Instance Attribute Details

#botObject (readonly)

Returns the value of attribute bot.



29
30
31
# File 'lib/vk_longpoll_bot/events.rb', line 29

def bot
  @bot
end

#dataObject (readonly)

Returns the value of attribute data.



29
30
31
# File 'lib/vk_longpoll_bot/events.rb', line 29

def data
  @data
end

#group_idObject (readonly)

Returns the value of attribute group_id.



29
30
31
# File 'lib/vk_longpoll_bot/events.rb', line 29

def group_id
  @group_id
end

#subtypeObject (readonly)

Returns the value of attribute subtype.



29
30
31
# File 'lib/vk_longpoll_bot/events.rb', line 29

def subtype
  @subtype
end

Instance Method Details

#[](arg) ⇒ Object

Provides access to fields of update data.



40
41
42
# File 'lib/vk_longpoll_bot/events.rb', line 40

def [](arg)
  @data[arg.to_s]
end