require 'zlib' # Module for the main vrobot4 program and global info. module Vrobot4 # The current program version. Version = "4.01".freeze # Sets the current debug level. # @param set [Integer] the debug level # @return [void] def self.set_debug set @@debug = set end # Logs to the console. # # @param lv [Symbol] the log level # [+:INFO+] This message will always be printed. # [+:DEBUG+] This message will not be printed if the global debug level is # less than 1. # [+:DEBUGV+] This message will not be printed if the global debug level is # less than 2. # @return [Boolean] true if the message was printed, false otherwise def self.log lv, text if (lv != :DEBUG || @@debug >= 1) && (lv != :DEBUGV || @@debug >= 2) puts "[#{lv.to_s.ljust 6}] #{text}" true else false end end # Checks if the argument +s+ is a numeric string. # @param s [String] the string to check # @return [Boolean] true if +s+ is a numeric string, false otherwise def self.is_num? s /\A[-+]?[0-9]*\.?[0-9]+\Z/ === s end # Does a stable hash on +s+. # @param s [String] the string to hash # @return [Integer] def self.hash_str s Zlib.crc32 s end end ## EOF