Class: AutomationObject::State::Top
- Defined in:
- lib/automation_object/state/top.rb
Overview
Top composite for managing state
Instance Attribute Summary
Attributes inherited from Base
Attributes inherited from Composite
#children, #location, #name, #parent
Instance Method Summary collapse
-
#active_screens ⇒ Hash<Screen>
Active screens.
-
#initialize(driver, blue_prints, name = :top, parent = nil, location = 'top') ⇒ Top
constructor
A new instance of Top.
-
#screens ⇒ Hash<Screen>
Children for this composite.
-
#set_initial_screen ⇒ Symbol
Get the initial screen.
- #start ⇒ Void
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
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
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_screens ⇒ Hash<Screen>
Returns active screens
53 54 55 |
# File 'lib/automation_object/state/top.rb', line 53 def active_screens screens.select { |_key, value| value.active? } end |
#screens ⇒ Hash<Screen>
Children for this composite
14 |
# File 'lib/automation_object/state/top.rb', line 14 has_many :screens, interface: Screen |
#set_initial_screen ⇒ Symbol
Get the initial screen
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 |
#start ⇒ 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 |