Sha256: c83acaf44f7992f534107e26047f4861e5f97b296ff30090e1bb7d6fa03a68eb
Contents?: true
Size: 1015 Bytes
Versions: 3
Compression:
Stored size: 1015 Bytes
Contents
# # A catch-all bag for stuff I don't have elsewhere yet. # module Utilities require 'timeout' POLL_SLEEP_TIME = 0.01 DEFAULT_TIMEOUT = 5 # The lambda passed to await should return false if thing not found # and something truthy if found def await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) Timeout.timeout(timeout) do loop do result = lamb.call return result if result # rubocop:disable Style/SleepCop sleep poll_sleep_time # rubocop:enable Style/SleepCop end end end def class_info(object) result = "CLASS: #{object.class}" result += "\nmethods: #{(object.methods - Class.methods).sort}\n" result end # Just call "caller" with no args for stack trace. def location caller(1..1).first end def page?(checkme) checkme.ancestors.include?(RUTL::Page) rescue NoMethodError # This isn't a even a class. It's no page! false end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rutl-0.6.0 | lib/utilities.rb |
rutl-0.5.0 | lib/utilities.rb |
rutl-0.4.0 | lib/utilities.rb |