Module: Ellington::HasTargets

Included in:
Line, Route
Defined in:
lib/ellington/has_targets.rb

Instance Method Summary collapse

Instance Method Details

#error_targetObject Also known as: errored



13
14
15
16
17
# File 'lib/ellington/has_targets.rb', line 13

def error_target
  @error_target ||= begin
    Ellington::Target.new states.keys - goal - fail_target
  end
end

#fail_targetObject Also known as: failed



4
5
6
7
8
9
10
# File 'lib/ellington/has_targets.rb', line 4

def fail_target
  @non_goal_target ||= begin
    state_list = states.keys - goal
    state_list.reject! { |state| state.to_s =~ /\AERROR/ }
    Ellington::Target.new *state_list
  end
end

#state(passenger) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/ellington/has_targets.rb', line 28

def state(passenger)
  case
  when passed.satisfied?(passenger) then "PASS"
  when failed.satisfied?(passenger) then "FAIL"
  when errored.satisfied?(passenger) then "ERROR"
  else
    nil
  end
end

#state_names(states) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ellington/has_targets.rb', line 20

def state_names(states)
  names = []
  names << "PASS" if (states & passed).length == passed.length
  names << "FAIL" if (states & failed).length == failed.length
  names << "ERROR" if (states & errored).length == errored.length
  names
end