Class: AutomationObject::State::Base
- Defined in:
- lib/automation_object/state/_base.rb
Overview
Parent composite class
Direct Known Subclasses
AutomaticModalChange, AutomaticScreenChanges, Element, ElementArray, ElementHash, Hook, HookAction, Modal, Screen, Top
Instance Attribute Summary collapse
- #blue_prints ⇒ AutomationObject::BluePrint::Composite::Base
- #driver ⇒ AutomationObject::Driver::Driver
Attributes inherited from Composite
#children, #location, #name, #parent
Instance Method Summary collapse
-
#get_child(name, args) ⇒ Object
Overriding base get_child method.
-
#get_children(name, args) ⇒ Object
Overriding base get_children method.
-
#initialize(driver, blue_prints, name = :top, parent = nil, location = 'top') ⇒ Base
constructor
A new instance of Base.
-
#screen ⇒ AutomationObject::State::Screen?
Recursive function to reach parent screen Can return nil if above a screen!.
-
#top ⇒ AutomationObject::State::Top
Recursive function to reach top.
Methods inherited from Composite
#add_has_many_relationships, #add_has_one_relationships, has_many, has_many_relationships, has_one, has_one_relationships
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') ⇒ Base
Returns a new instance of Base
20 21 22 23 24 25 |
# File 'lib/automation_object/state/_base.rb', line 20 def initialize(driver, blue_prints, name = :top, parent = nil, location = 'top') self.driver = driver self.blue_prints = blue_prints super(name, parent, location) end |
Instance Attribute Details
#blue_prints ⇒ AutomationObject::BluePrint::Composite::Base
13 14 15 |
# File 'lib/automation_object/state/_base.rb', line 13 def blue_prints @blue_prints end |
#driver ⇒ AutomationObject::Driver::Driver
10 11 12 |
# File 'lib/automation_object/state/_base.rb', line 10 def driver @driver end |
Instance Method Details
#get_child(name, args) ⇒ Object
Overriding base get_child method
30 31 32 33 34 35 36 |
# File 'lib/automation_object/state/_base.rb', line 30 def get_child(name, args) child_location = location + "[#{name}]" args.fetch(:interface).new(driver, blue_prints.send(name), name, self, child_location) end |
#get_children(name, args) ⇒ Object
Overriding base get_children method
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/automation_object/state/_base.rb', line 42 def get_children(name, args) children_hash = {} blue_prints.send(name).each do |child_key, child_blue_prints| child_location = location + "[#{child_key}]" children_hash[child_key] = args.fetch(:interface).new(driver, child_blue_prints, child_key, self, child_location) end children_hash end |
#screen ⇒ AutomationObject::State::Screen?
Recursive function to reach parent screen Can return nil if above a screen!
59 60 61 62 63 64 |
# File 'lib/automation_object/state/_base.rb', line 59 def screen return nil if is_a?(Top) # Should recursively call top until parent is nil is_a?(Screen) ? self : parent.screen end |
#top ⇒ AutomationObject::State::Top
Recursive function to reach top
68 69 70 |
# File 'lib/automation_object/state/_base.rb', line 68 def top is_a?(Top) ? self : parent.top end |