Class: OpenRTB::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/openrtb/client.rb

Defined Under Namespace

Classes: Queue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



58
59
60
# File 'lib/openrtb/client.rb', line 58

def initialize
  yield(self) if block_given?
end

Instance Attribute Details

#loggerObject



62
63
64
# File 'lib/openrtb/client.rb', line 62

def logger
  @logger ||= OpenRTB::NullObject.new
end

#max_concurrencyObject



66
67
68
# File 'lib/openrtb/client.rb', line 66

def max_concurrency
  @max_concurrency ||= 2
end

#proxyObject

Returns the value of attribute proxy.



10
11
12
# File 'lib/openrtb/client.rb', line 10

def proxy
  @proxy
end

#user_agentObject



70
71
72
# File 'lib/openrtb/client.rb', line 70

def user_agent
  @user_agent ||= "OpenRTB Ruby Client #{OpenRTB::VERSION}"
end

#versionObject



74
75
76
# File 'lib/openrtb/client.rb', line 74

def version
  @version ||= '2.1'
end

Instance Method Details

#execute(&block) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/openrtb/client.rb', line 78

def execute(&block)
  hydra = Typhoeus::Hydra.new(max_concurrency: max_concurrency)
  queue = Queue.new(self, hydra)
  block.call(queue)
  hydra.run

  handle_responses(queue.responses)
end