Class: VkCozy::UserEvent
- Inherits:
-
Object
- Object
- VkCozy::UserEvent
- Defined in:
- lib/vk_cozy/dispatch/views/user/event.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#extra_values ⇒ Object
Returns the value of attribute extra_values.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#from_chat ⇒ Object
Returns the value of attribute from_chat.
-
#from_group ⇒ Object
Returns the value of attribute from_group.
-
#from_me ⇒ Object
Returns the value of attribute from_me.
-
#from_user ⇒ Object
Returns the value of attribute from_user.
-
#message_data ⇒ Object
Returns the value of attribute message_data.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#peer_id ⇒ Object
Returns the value of attribute peer_id.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#text ⇒ Object
Returns the value of attribute text.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#to_me ⇒ Object
Returns the value of attribute to_me.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_id ⇒ Object
Returns the value of attribute type_id.
Instance Method Summary collapse
- #answer(text) ⇒ Object
-
#initialize(api, raw_event) ⇒ UserEvent
constructor
A new instance of UserEvent.
- #to_s ⇒ Object
Constructor Details
#initialize(api, raw_event) ⇒ UserEvent
Returns a new instance of UserEvent.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 8 def initialize(api, raw_event) @api = api @raw = raw_event @from_user = false @from_chat = false @from_group = false @from_me = false @to_me = false begin @type = UserEventType.parse(@raw[0]) list_to_attr(@raw[1, @raw.length], EVENT_ATTRS_MAPPING[@type]) rescue StandardError => e @type = @raw[0] end if VkCozy::PARSE_PEER_ID_EVENTS.include?(@type) parse_peer_id() end if VkCozy::PARSE_MESSAGE_FLAGS_EVENTS () end end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def api @api end |
#attachments ⇒ Object
Returns the value of attribute attachments.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def @attachments end |
#extra ⇒ Object
Returns the value of attribute extra.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def extra @extra end |
#extra_values ⇒ Object
Returns the value of attribute extra_values.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def extra_values @extra_values end |
#flags ⇒ Object
Returns the value of attribute flags.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def flags @flags end |
#from_chat ⇒ Object
Returns the value of attribute from_chat.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def from_chat @from_chat end |
#from_group ⇒ Object
Returns the value of attribute from_group.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def from_group @from_group end |
#from_me ⇒ Object
Returns the value of attribute from_me.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def from_me @from_me end |
#from_user ⇒ Object
Returns the value of attribute from_user.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def from_user @from_user end |
#message_data ⇒ Object
Returns the value of attribute message_data.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def @message_data end |
#message_id ⇒ Object
Returns the value of attribute message_id.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def @message_id end |
#peer_id ⇒ Object
Returns the value of attribute peer_id.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def peer_id @peer_id end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def raw @raw end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def text @text end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def @timestamp end |
#to_me ⇒ Object
Returns the value of attribute to_me.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def to_me @to_me end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def type @type end |
#type_id ⇒ Object
Returns the value of attribute type_id.
3 4 5 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 3 def type_id @type_id end |
Instance Method Details
#answer(text) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 40 def answer(text) return @api.( peer_id: @peer_id, message: text, random_id: 0 ) end |
#to_s ⇒ Object
34 35 36 37 38 |
# File 'lib/vk_cozy/dispatch/views/user/event.rb', line 34 def to_s instance_variables.each_with_object({}) do |k, h| h[k] = instance_variable_get("#{k}") end.to_json end |