Class: Crabfarm::BaseNavigator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Assertion::Context, Base, Live::Interactable
Defined in:
lib/crabfarm/base_navigator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Live::Interactable

#examine, included

Methods included from Assertion::Context

#assert

Methods included from Base

#debugger

Constructor Details

#initialize(_context, _params) ⇒ BaseNavigator



18
19
20
21
# File 'lib/crabfarm/base_navigator.rb', line 18

def initialize(_context,  _params)
  @context = _context
  @params = _params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



14
15
16
# File 'lib/crabfarm/base_navigator.rb', line 14

def params
  @params
end

Instance Method Details

#browser(_name = nil) ⇒ Object



29
30
31
# File 'lib/crabfarm/base_navigator.rb', line 29

def browser(_name=nil)
  @context.pool.driver(_name)
end

#fork_each(_enumerator, &_block) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/crabfarm/base_navigator.rb', line 50

def fork_each(_enumerator, &_block)
  session_id = 0
  mutex = Mutex.new
  ths = _enumerator.map do |value|
    session_id += 1
    start_forked_navigation("th_session_#{session_id}", value, _block, mutex)
  end
  ThreadsWait.all_waits(*ths)
end


23
24
25
# File 'lib/crabfarm/base_navigator.rb', line 23

def navigate(_name, _params={})
  TransitionService.transition(@context, _name, params.merge(_params))
end

#reduce(_target = nil, _options = {}) ⇒ Object Also known as: reduce_with_defaults



37
38
39
40
41
42
43
44
45
46
# File 'lib/crabfarm/base_navigator.rb', line 37

def reduce(_target=nil, _options={})
  if _target.is_a? Hash
    _options = _target
    _target = browser
  elsif _target.nil?
    _target = browser
  end

  reduce_using(_options.delete(:using) || self.class.name, _target, _options)
end

#runObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/crabfarm/base_navigator.rb', line 33

def run
  raise NotImplementedError.new
end