Class: AutomationObject::State::Top

Inherits:
Base show all
Defined in:
lib/automation_object/state/top.rb

Overview

Top composite for managing state

Instance Attribute Summary

Attributes inherited from Base

#blue_prints, #driver

Attributes inherited from Composite

#children, #location, #name, #parent

Instance Method Summary collapse

Methods inherited from Base

#get_child, #get_children, #screen, #top

Methods inherited from Composite

#add_has_many_relationships, #add_has_one_relationships, #get_child, #get_children, has_many, has_many_relationships, has_one, has_one_relationships, #top

Methods included from Reflection

#add_alias, #add_attribute

Methods included from CompositeHook

#after_create_run, #before_create_run, included

Constructor Details

#initialize(driver, blue_prints, name = :top, parent = nil, location = 'top') ⇒ Top

Returns a new instance of Top

Parameters:



21
22
23
# File 'lib/automation_object/state/top.rb', line 21

def initialize(driver, blue_prints, name = :top, parent = nil, location = 'top')
  super
end

Instance Method Details

#active_screensHash<Screen>

Returns active screens

Returns:



53
54
55
# File 'lib/automation_object/state/top.rb', line 53

def active_screens
  screens.select { |_key, value| value.active? }
end

#screensHash<Screen>

Children for this composite

Returns:



14
# File 'lib/automation_object/state/top.rb', line 14

has_many :screens, interface: Screen

#set_initial_screenSymbol

Get the initial screen

Returns:

  • (Symbol)

    screen name

Raises:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/automation_object/state/top.rb', line 34

def set_initial_screen
  # If default screen then check if its live and set it
  if blue_prints.default_screen
    default_name = blue_prints.default_screen

    raise AutomationObject::State::NoInitialScreenError if screens[default_name].load.live? == false

    return screens[default_name].activate
  end

  screens.each_value do |screen|
    next unless screen.load.live?
    return screen.activate
  end

  raise AutomationObject::State::NoInitialScreenError
end

#startVoid

Returns:

  • (Void)


26
27
28
29
# File 'lib/automation_object/state/top.rb', line 26

def start
  driver.get(blue_prints.base_url) if blue_prints.base_url
  set_initial_screen
end