Module: BrineUtil
- Included in:
- Brine
- Defined in:
- lib/brine/util.rb
Overview
Assorted utility functions
Instance Method Summary collapse
-
#retry_for(time, interval = 1) ⇒ Object
reevaluate passed block until it returns without throwing an exception or ‘time` elapses; retry every `interval`.
-
#transform_table!(table) ⇒ Object
iterate over data table and shave_value for each cell value mutates and returns table FIXME: Shouldn’t be needed and removed after use of tables is dropped.
Instance Method Details
#retry_for(time, interval = 1) ⇒ Object
reevaluate passed block until it returns without throwing an exception or ‘time` elapses; retry every `interval`
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/brine/util.rb', line 5 def retry_for(time, interval=1) failure = nil quit = Time.now + time while (Time.now <= quit) begin return yield rescue Exception => ex failure = ex sleep interval end end raise failure end |
#transform_table!(table) ⇒ Object
iterate over data table and shave_value for each cell value mutates and returns table FIXME: Shouldn’t be needed and removed after use of tables is dropped
22 23 24 25 26 27 |
# File 'lib/brine/util.rb', line 22 def transform_table!(table) table.cells_rows.each do |row| row.each{|cell| cell.value = Transform(cell.value)} end table end |