Class: VkLongpollBot::Events::Event
- Inherits:
-
Object
- Object
- VkLongpollBot::Events::Event
- Defined in:
- lib/vk_longpoll_bot/events.rb
Overview
Class containing data received from longpoll. Provides easy access to it’s data.
Instance Attribute Summary collapse
-
#bot ⇒ Bot
readonly
Longpoll bot which received event.
-
#data ⇒ Hash
readonly
Hash with updates data.
-
#group_id ⇒ Integer
readonly
ID of group which received event.
-
#subtype ⇒ String
readonly
Subtype of event.
Instance Method Summary collapse
-
#[](arg) ⇒ Object
Provides access to fields of update data.
-
#initialize(subtype, data, group_id, bot) ⇒ Event
constructor
New event.
Constructor Details
#initialize(subtype, data, group_id, bot) ⇒ Event
New event. Initialize from fields of update json and bot which got this event.
59 60 61 62 63 64 |
# File 'lib/vk_longpoll_bot/events.rb', line 59 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
#bot ⇒ Bot (readonly)
Returns longpoll bot which received event.
50 51 52 |
# File 'lib/vk_longpoll_bot/events.rb', line 50 def bot @bot end |
#data ⇒ Hash (readonly)
Returns hash with updates data.
46 47 48 |
# File 'lib/vk_longpoll_bot/events.rb', line 46 def data @data end |
#group_id ⇒ Integer (readonly)
Returns ID of group which received event.
42 43 44 |
# File 'lib/vk_longpoll_bot/events.rb', line 42 def group_id @group_id end |
#subtype ⇒ String (readonly)
Returns subtype of event.
38 39 40 |
# File 'lib/vk_longpoll_bot/events.rb', line 38 def subtype @subtype end |
Instance Method Details
#[](arg) ⇒ Object
Provides access to fields of update data.
72 73 74 |
# File 'lib/vk_longpoll_bot/events.rb', line 72 def [](arg) @data[arg.to_s] end |