Class: Lightpanda::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/lightpanda/options.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
ENV.fetch("LIGHTPANDA_DEFAULT_TIMEOUT", 5).to_i
DEFAULT_PROCESS_TIMEOUT =
ENV.fetch("LIGHTPANDA_PROCESS_TIMEOUT", 10).to_i
DEFAULT_HOST =
"127.0.0.1"
DEFAULT_PORT =
9222
DEFAULT_WINDOW_SIZE =
[1024, 768].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



14
15
16
17
18
19
20
21
22
23
# File 'lib/lightpanda/options.rb', line 14

def initialize(options = {})
  @host = options.fetch(:host, DEFAULT_HOST)
  @port = options.fetch(:port, DEFAULT_PORT)
  @timeout = options.fetch(:timeout, DEFAULT_TIMEOUT)
  @process_timeout = options.fetch(:process_timeout, DEFAULT_PROCESS_TIMEOUT)
  @window_size = options.fetch(:window_size, DEFAULT_WINDOW_SIZE)
  @browser_path = options[:browser_path]
  @headless = options.fetch(:headless, true)
  @ws_url = options[:ws_url]
end

Instance Attribute Details

#browser_pathObject

Returns the value of attribute browser_path.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def browser_path
  @browser_path
end

#headlessObject

Returns the value of attribute headless.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def headless
  @headless
end

#hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def host
  @host
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def port
  @port
end

#process_timeoutObject

Returns the value of attribute process_timeout.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def process_timeout
  @process_timeout
end

#timeoutObject

Returns the value of attribute timeout.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def timeout
  @timeout
end

#window_sizeObject

Returns the value of attribute window_size.



11
12
13
# File 'lib/lightpanda/options.rb', line 11

def window_size
  @window_size
end

#ws_urlObject



25
26
27
# File 'lib/lightpanda/options.rb', line 25

def ws_url
  @ws_url || "ws://#{host}:#{port}/"
end

Instance Method Details

#to_hObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lightpanda/options.rb', line 33

def to_h
  {
    host: host,
    port: port,
    timeout: timeout,
    process_timeout: process_timeout,
    window_size: window_size,
    browser_path: browser_path,
    headless: headless,
    ws_url: ws_url
  }
end

#ws_url?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/lightpanda/options.rb', line 29

def ws_url?
  !@ws_url.nil?
end