Class: Cryptsy::ConfirmationPoller

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptsy/confirmation_poller.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter, pattern) ⇒ ConfirmationPoller

Returns a new instance of ConfirmationPoller.

Parameters:

  • adapter (Object)
  • pattern (Regexp)


7
8
9
10
# File 'lib/cryptsy/confirmation_poller.rb', line 7

def initialize(adapter, pattern)
  @adapter = adapter
  @pattern = pattern
end

Instance Method Details

#run_onceEnumerable

Returns:

  • (Enumerable)


13
14
15
16
17
18
19
20
21
# File 'lib/cryptsy/confirmation_poller.rb', line 13

def run_once
  links = []

  @adapter.call do |email|
    scan_links(links, email)
  end

  links
end

#run_until_found(sleep_interval = 3) ⇒ void

This method returns an undefined value.

Parameters:

  • sleep_interval (Integer) (defaults to: 3)


25
26
27
28
29
30
31
# File 'lib/cryptsy/confirmation_poller.rb', line 25

def run_until_found(sleep_interval = 3)
  loop do
    links = run_once
    return links unless links.empty?
    sleep sleep_interval
  end
end