Class: VkCozy::User
- Inherits:
-
Object
- Object
- VkCozy::User
- Defined in:
- lib/vk_cozy/user.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
-
#initialize(access_token, version = 5.92) ⇒ User
constructor
A new instance of User.
- #on ⇒ Object
- #on_startup ⇒ Object
- #run_polling(startup = nil) ⇒ Object
Constructor Details
#initialize(access_token, version = 5.92) ⇒ User
Returns a new instance of User.
10 11 12 13 14 15 16 |
# File 'lib/vk_cozy/user.rb', line 10 def initialize(access_token, version=5.92) @access_token = access_token @api = Api.new(access_token, version) @polling = VkCozy::UserPolling.new(@api) @labeler = VkCozy::UserLabeler.new(@api) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
8 9 10 |
# File 'lib/vk_cozy/user.rb', line 8 def api @api end |
Instance Method Details
#on ⇒ Object
18 19 20 |
# File 'lib/vk_cozy/user.rb', line 18 def on return @labeler end |
#on_startup ⇒ Object
22 23 24 |
# File 'lib/vk_cozy/user.rb', line 22 def on_startup puts 'Run polling' end |
#run_polling(startup = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vk_cozy/user.rb', line 26 def run_polling(startup=nil) if startup.nil? on_startup elsif startup.is_a?(Proc) startup.call else startup end @polling.listen do |event| for update in event['updates'] begin if @labeler.filter(update) next end rescue Exception => e raise e end end end end |