Module: Utilities
- Included in:
- RUTL::Browser, RUTL::Interface::Base
- Defined in:
- lib/utilities.rb
Overview
A catch-all bag for stuff I don’t have elsewhere yet.
Constant Summary collapse
- POLL_SLEEP_TIME =
0.01
- DEFAULT_TIMEOUT =
5
Instance Method Summary collapse
-
#await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) ⇒ Object
The lambda passed to await should return false if thing not found and something truthy if found.
- #class_info(object) ⇒ Object
-
#location ⇒ Object
Just call “caller” with no args for stack trace.
- #page?(checkme) ⇒ Boolean
Instance Method Details
#await(lamb, timeout = DEFAULT_TIMEOUT, poll_sleep_time = POLL_SLEEP_TIME) ⇒ Object
The lambda passed to await should return false if thing not found and something truthy if found
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/utilities.rb', line 12 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 |
#class_info(object) ⇒ Object
24 25 26 27 28 |
# File 'lib/utilities.rb', line 24 def class_info(object) result = "CLASS: #{object.class}" result += "\nmethods: #{(object.methods - Class.methods).sort}\n" result end |
#location ⇒ Object
Just call “caller” with no args for stack trace.
31 32 33 |
# File 'lib/utilities.rb', line 31 def location caller(1..1).first end |
#page?(checkme) ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/utilities.rb', line 35 def page?(checkme) checkme.ancestors.include?(RUTL::Page) rescue NoMethodError # This isn't a even a class. It's no page! false end |