Class: AutomationObject::Dsl::ScreenProxy

Inherits:
Proxy show all
Defined in:
lib/automation_object/dsl/screen.rb

Overview

Proxy for Screen

Instance Method Summary collapse

Constructor Details

#initialize(blue_prints, state, name) ⇒ ScreenProxy

Returns a new instance of ScreenProxy

Parameters:



27
28
29
# File 'lib/automation_object/dsl/screen.rb', line 27

def initialize(blue_prints, state, name)
  super Screen, blue_prints, state, name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Parameters:

  • method (Symbol)
  • args (Array, nil)
  • block (Proc)


34
35
36
37
38
39
40
41
# File 'lib/automation_object/dsl/screen.rb', line 34

def method_missing(method, *args, &block)
  return super if Screen.methods.include?(method)

  # Attempt to load screen if composite object contains that child
  @state.utilize if @subject.to_h.include?(method)

  super
end

Instance Method Details

#active?Boolean

Is the screen active

Returns:

  • (Boolean)


45
46
47
# File 'lib/automation_object/dsl/screen.rb', line 45

def active?
  @state.active?
end

#closevoid

This method returns an undefined value.

Close screen



51
52
53
# File 'lib/automation_object/dsl/screen.rb', line 51

def close
  @state.close
end

#element(name) ⇒ AutomationObject::Dsl::ElementProxy

Retrieve element from composite

Parameters:

  • name (String, Symbol)

    name of element

Returns:

Raises:



80
81
82
83
84
85
86
# File 'lib/automation_object/dsl/screen.rb', line 80

def element(name)
  name = name.to_sym
  raise AutomationObject::Dsl::Error::ElementDoesNotExistError, name unless @subject.to_h.include?(name)

  @state.utilize
  @subject.send(name)
end

#element_array(name) ⇒ AutomationObject::Dsl::ElementArrayProxy

Retrieve element array from composite

Parameters:

  • name (String, Symbol)

    name of element array

Returns:

Raises:



92
93
94
95
96
97
98
# File 'lib/automation_object/dsl/screen.rb', line 92

def element_array(name)
  name = name.to_sym
  raise AutomationObject::Dsl::Error::ElementArrayDoesNotExistError, name unless @subject.to_h.include?(name)

  @state.utilize
  @subject.send(name)
end

#element_hash(name) ⇒ AutomationObject::Dsl::ElementHashProxy

Retrieve element hash from composite

Parameters:

  • name (String, Symbol)

    name of element hash

Returns:

Raises:



104
105
106
107
108
109
110
# File 'lib/automation_object/dsl/screen.rb', line 104

def element_hash(name)
  name = name.to_sym
  raise AutomationObject::Dsl::Error::ElementHashDoesNotExistError, name unless @subject.to_h.include?(name)

  @state.utilize
  @subject.send(name)
end

#goBoolean

Go to this screen Will try to automatically reach it, will throw error if it cannot

Returns:

  • (Boolean)

Raises:

  • (AutomationObject::Dsl::Error::AutoReachScreenError)


59
60
61
# File 'lib/automation_object/dsl/screen.rb', line 59

def go
  @state.go
end

Retrieve modal or self from composite

Parameters:

  • name (String, Symbol)

    name of modal

Returns:

Raises:

  • (AutomationObject::Dsl::Error::ModalDoesNotExistError)


66
67
68
69
70
71
72
73
74
# File 'lib/automation_object/dsl/screen.rb', line 66

def modal(name)
  name = name.to_sym
  raise AutomationObject::Dsl::Error::ModalDoesNotExistError, name unless @subject.to_h.include?(name)

  @state.utilize
  return @subject.send(name) if @subject.send(name)

  self
end