Class: QAT::Web::Screen::Wrapper

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/qat/web/screen/wrapper.rb

Overview

Screen wrapper to represent an abstract display. Can have a Headless instance associated.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Wrapper

Create a new screen.

Parameters:

  • name (String)

    screen name

  • options (Hash)

    start options

Options Hash (options):

  • :dimensions (String)

    Screen dimensions (‘800x600x24’)

Since:

  • 1.0.0



43
44
45
46
47
48
49
# File 'lib/qat/web/screen/wrapper.rb', line 43

def initialize name, options
  @name    = name
  @options = options
  parse_resolution options
  log.info "Created screen with #{width}x#{height}x#{depth}"
  @xvfb = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Redirect all unknown methods to the Xvfb instance

Since:

  • 1.0.0



72
73
74
# File 'lib/qat/web/screen/wrapper.rb', line 72

def method_missing method, *args, &block
  @xvfb.method(method).call *args, &block
end

Instance Attribute Details

#depthString (readonly)

Returns Screen depth.

Returns:

  • (String)

    Screen depth

Since:

  • 1.0.0



32
33
34
# File 'lib/qat/web/screen/wrapper.rb', line 32

def depth
  @depth
end

#heightString (readonly)

Returns Screen height.

Returns:

  • (String)

    Screen height

Since:

  • 1.0.0



28
29
30
# File 'lib/qat/web/screen/wrapper.rb', line 28

def height
  @height
end

#nameString (readonly)

Returns Screen name.

Returns:

  • (String)

    Screen name

Since:

  • 1.0.0



16
17
18
# File 'lib/qat/web/screen/wrapper.rb', line 16

def name
  @name
end

#optionsHash (readonly)

Returns Initialization options.

Returns:

  • (Hash)

    Initialization options

Since:

  • 1.0.0



20
21
22
# File 'lib/qat/web/screen/wrapper.rb', line 20

def options
  @options
end

#widthString (readonly)

Returns Screen width.

Returns:

  • (String)

    Screen width

Since:

  • 1.0.0



24
25
26
# File 'lib/qat/web/screen/wrapper.rb', line 24

def width
  @width
end

#xvfbHeadless (readonly)

Returns Xvfb instance representing the screen.

Returns:

  • (Headless)

    Xvfb instance representing the screen

Since:

  • 1.0.0



36
37
38
# File 'lib/qat/web/screen/wrapper.rb', line 36

def xvfb
  @xvfb
end

Instance Method Details

#destroyObject

Destroy the Xvfb instance

Since:

  • 1.0.0



63
64
65
66
67
68
# File 'lib/qat/web/screen/wrapper.rb', line 63

def destroy
  return unless @xvfb
  @xvfb.destroy
  log.info "Xvfb #{name} screen destroyed"
  @xvfb = nil
end

#startHeadless

Start a new Xvfb instance

Returns:

Since:

  • 1.0.0



54
55
56
57
58
59
# File 'lib/qat/web/screen/wrapper.rb', line 54

def start
  @xvfb = Headless.new @options
  @xvfb.start
  log.info "Xvfb #{name} screen started"
  @xvfb
end