Class: VkCozy::BotEvent
- Inherits:
-
Object
- Object
- VkCozy::BotEvent
- Defined in:
- lib/vk_cozy/dispatch/views/bot/event.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#client_info ⇒ Object
readonly
Returns the value of attribute client_info.
-
#group_id ⇒ Object
readonly
Returns the value of attribute group_id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#t ⇒ Object
readonly
Returns the value of attribute t.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #answer(text) ⇒ Object
-
#initialize(api, event_raw) ⇒ BotEvent
constructor
A new instance of BotEvent.
- #to_s ⇒ Object
Constructor Details
#initialize(api, event_raw) ⇒ BotEvent
Returns a new instance of BotEvent.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 4 def initialize(api, event_raw) @api = api @raw = event_raw @type = event_raw['type'] @t = @type @object = event_raw['object'].to_dot @obj = @object @message = @obj['message'] @client_info = @obj['client_info'] @group_id = @raw['group_id'] end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def api @api end |
#client_info ⇒ Object (readonly)
Returns the value of attribute client_info.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def client_info @client_info end |
#group_id ⇒ Object (readonly)
Returns the value of attribute group_id.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def group_id @group_id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def @message end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def obj @obj end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def object @object end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def raw @raw end |
#t ⇒ Object (readonly)
Returns the value of attribute t.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def t @t end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 3 def type @type end |
Instance Method Details
#[](key) ⇒ Object
30 31 32 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 30 def [] key instance_variable_get("@#{key}") end |
#answer(text) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 22 def answer(text) return @api.( peer_id: @obj.peer_id, message: text, random_id: 0 ) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/vk_cozy/dispatch/views/bot/event.rb', line 34 def to_s "BotEvent(#{@raw.to_s})" end |