class AutomationObject::State::Top

Top composite for managing state

Public Class Methods

new(driver, blue_prints, name = :top, parent = nil, location = 'top') click to toggle source

@param driver [AutomationObject::Driver] driver @param blue_prints [AutomationObject::BluePrint::Composite::Base] blue print composite @param name [Symbol] name of composite element @param parent [Object, nil] parent composite object @param location [String] string location for error/debugging purposes

Calls superclass method AutomationObject::State::Base::new
# File lib/automation_object/state/top.rb, line 21
def initialize(driver, blue_prints, name = :top, parent = nil, location = 'top')
  super
end

Public Instance Methods

active_screens() click to toggle source

@return [Hash<Screen>] active screens

# File lib/automation_object/state/top.rb, line 53
def active_screens
  screens.select { |_key, value| value.active? }
end
set_initial_screen() click to toggle source

Get the initial screen @raise [AutomationObject::State::NoInitialScreenError] if no initial screen @return [Symbol] screen name

# 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
start() click to toggle source

@return [Void]

# 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