Module: VkLongpollBot::Utility

Defined in:
lib/vk_longpoll_bot/utility.rb

Overview

Module with some utility methods.

Class Method Summary collapse

Class Method Details

.random_id(target_id) ⇒ Object

Generate random_id for message.



16
17
18
# File 'lib/vk_longpoll_bot/utility.rb', line 16

def self.random_id(target_id)
  (rand(1000) * target_id * Time.now.to_f * 1000).to_i % 2**32
end

.warn(msg) ⇒ Object

Log warning.



7
8
9
10
11
12
13
# File 'lib/vk_longpoll_bot/utility.rb', line 7

def self.warn(msg)
  if defined?(Warning.warn)
    Warning.warn msg
  else
    STDERR.puts "Warning: #{msg}"
  end
end