Class: RequestRepeater::RequestMaker

Inherits:
Object
  • Object
show all
Defined in:
lib/request_repeater/request_maker.rb

Constant Summary collapse

InvalidURL =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoints) ⇒ RequestMaker

Returns a new instance of RequestMaker.



8
9
10
# File 'lib/request_repeater/request_maker.rb', line 8

def initialize(endpoints)
  @endpoints = endpoints
end

Instance Attribute Details

#endpointsObject (readonly)

Returns the value of attribute endpoints.



5
6
7
# File 'lib/request_repeater/request_maker.rb', line 5

def endpoints
  @endpoints
end

#sleeper=(value) ⇒ Object

Sets the attribute sleeper

Parameters:

  • value

    the value to set the attribute sleeper to.



6
7
8
# File 'lib/request_repeater/request_maker.rb', line 6

def sleeper=(value)
  @sleeper = value
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/request_repeater/request_maker.rb', line 12

def run
  loop do
    endpoints.each do |e|
      e.execute do
        request(e.uri)
      end
    end
    sleeper.call(minimum_sleep)
  end
end