Class: Zander::Site
- Inherits:
-
Object
- Object
- Zander::Site
- Defined in:
- lib/zander/site.rb
Instance Method Summary collapse
-
#add_actions(actions) ⇒ Object
Map each hash in actions array with CommandMapper.
- #drive ⇒ Object
-
#initialize(parent:, hash:, driver:, log:) ⇒ Site
constructor
A new instance of Site.
- #inspect ⇒ Object
-
#last? ⇒ Boolean
Is this instance the last Site object defined in share/sites.yaml.
- #mask(var) ⇒ Object
Constructor Details
#initialize(parent:, hash:, driver:, log:) ⇒ Site
Returns a new instance of Site.
4 5 6 7 8 9 10 11 |
# File 'lib/zander/site.rb', line 4 def initialize(parent:, hash:, driver:, log:) @actions = Array.new @parent = parent unless parent == nil @log = log unless log == nil @driver = driver unless driver == nil create_attr_accessor(hash) @log.debug("Created #{self}") end |
Instance Method Details
#add_actions(actions) ⇒ Object
Map each hash in actions array with CommandMapper. If the result is an Action object, add it to the acctions array
19 20 21 22 23 24 25 26 27 |
# File 'lib/zander/site.rb', line 19 def add_actions(actions) actions.each do |action| # convert keys in action hash to symbols action = action.keys_to_sym @log.debug("Create action #{action}") obj = CommandMapper.map(self, @driver, @log, action) @actions.push(obj) if obj.is_a?(Action) end end |
#drive ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/zander/site.rb', line 34 def drive() @driver.navigate.to self.url @log.info("Opened #{@driver.current_url}") @actions.each do |action| action.drive end end |
#inspect ⇒ Object
89 90 91 |
# File 'lib/zander/site.rb', line 89 def inspect to_s end |
#last? ⇒ Boolean
Is this instance the last Site object defined in share/sites.yaml
30 31 32 |
# File 'lib/zander/site.rb', line 30 def last? @url != nil && @parent.sites.last.respond_to?(:url) && @parent.sites.last.url == @url end |
#mask(var) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/zander/site.rb', line 80 def mask(var) clear = 3 #keep last 3 in clear text masked = var[0]; (var.length-(clear+1)).times do masked << '*' end masked << var[(var.length-clear)...var.length] end |