Module: QAT::Web::Screen::Factory

Includes:
Logger
Defined in:
lib/qat/web/screen/factory.rb

Overview

Module to provide virtual screens for web control.

Since:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.current_screenQAT::Screen::Wrapper

Current screen in use

Returns:

  • (QAT::Screen::Wrapper)

    current screen

Since:

  • 1.0.0



56
57
58
# File 'lib/qat/web/screen/factory.rb', line 56

def current_screen
  @current_screen ||= nil
end

.for(name = :default, load = true) ⇒ QAT::Screen::Wrapper

Method to ask for a virtual screen. It will be provided if Loader knows the screen definition. Will do nothing if ENV [‘QAT_DISPLAY’] is set to ‘none’

Parameters:

  • name (String/Symbol) (defaults to: :default)

    Name of the virtual screen to use

Returns:

  • (QAT::Screen::Wrapper)

    current screen

Raises:

  • (ArgumentError)

    When a given screen definition does not exist.

Since:

  • 1.0.0



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/qat/web/screen/factory.rb', line 21

def for name=:default, load=true

  name ||= :default

  name = name.to_sym

  unless QAT::Web::Screen::Loader.screens.has_key? name
    log.error { "No screen with name #{name} available" }
    log.debug { 'Available screens are:' }
    log.debug { QAT::Web::Screen::Loader.screens.keys }
    raise ArgumentError.new "No screen with name #{name} available"
  end

  current_screen.destroy if current_screen
  screen_definitions = QAT::Web::Screen::Loader.screens[name]
  if screen_definitions.empty?
    log.debug {'Using the default configuration definitions'}
    screen_definitions[:reuse] = false
  end
  self.current_screen =  QAT::Web::Screen::Wrapper.new name, screen_definitions

  if ENV['QAT_DISPLAY'] == 'none'
    log.info 'Virtual screens disabled'
  elsif not load
    log.info 'Virtual screen will not be loaded'
  else
    current_screen.start
  end

  current_screen
end