Class: CEML::Confluence
- Inherits:
-
Object
- Object
- CEML::Confluence
- Defined in:
- lib/ceml/confluence.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#incident_id ⇒ Object
(also: #launched?)
Returns the value of attribute incident_id.
-
#roles_to_cast ⇒ Object
Returns the value of attribute roles_to_cast.
-
#star ⇒ Object
Returns the value of attribute star.
Instance Method Summary collapse
- #best_role_for(candidate) ⇒ Object
- #cast ⇒ Object
- #cast_with?(candidate) ⇒ Boolean
- #full? ⇒ Boolean
-
#initialize(roles_to_cast, candidate = nil) ⇒ Confluence
constructor
A new instance of Confluence.
- #live_with?(candidate) ⇒ Boolean
- #over? ⇒ Boolean
- #push(candidate) ⇒ Object
- #rm(*candidates) ⇒ Object
- #stage_with_candidate(candidate) ⇒ Object
Constructor Details
#initialize(roles_to_cast, candidate = nil) ⇒ Confluence
Returns a new instance of Confluence.
9 10 11 12 13 14 |
# File 'lib/ceml/confluence.rb', line 9 def initialize roles_to_cast, candidate = nil @hash = {} @created = true @roles_to_cast = roles_to_cast push candidate if candidate end |
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
6 7 8 |
# File 'lib/ceml/confluence.rb', line 6 def created @created end |
#hash ⇒ Object
Returns the value of attribute hash.
6 7 8 |
# File 'lib/ceml/confluence.rb', line 6 def hash @hash end |
#incident_id ⇒ Object Also known as: launched?
Returns the value of attribute incident_id.
6 7 8 |
# File 'lib/ceml/confluence.rb', line 6 def incident_id @incident_id end |
#roles_to_cast ⇒ Object
Returns the value of attribute roles_to_cast.
6 7 8 |
# File 'lib/ceml/confluence.rb', line 6 def roles_to_cast @roles_to_cast end |
#star ⇒ Object
Returns the value of attribute star.
6 7 8 |
# File 'lib/ceml/confluence.rb', line 6 def star @star end |
Instance Method Details
#best_role_for(candidate) ⇒ Object
20 21 22 23 24 |
# File 'lib/ceml/confluence.rb', line 20 def best_role_for candidate # puts "confluence finding best role #{object_id} #{candidate[:id]} #{star}" winner = @roles_to_cast.max_by{ |role| role.affinity(candidate, star) } winner unless winner.affinity(candidate, star)[0] == -1 end |
#cast ⇒ Object
63 64 65 |
# File 'lib/ceml/confluence.rb', line 63 def cast @roles_to_cast.map{ |r| r.casted }.flatten end |
#cast_with?(candidate) ⇒ Boolean
55 56 57 |
# File 'lib/ceml/confluence.rb', line 55 def cast_with?(candidate) @roles_to_cast.any?{ |r| r.casted.any?{ |guy| guy[:id] == candidate[:id] } } end |
#full? ⇒ Boolean
47 48 49 |
# File 'lib/ceml/confluence.rb', line 47 def full? @roles_to_cast.all?{ |role| role.allowed == 0 } end |
#live_with?(candidate) ⇒ Boolean
59 60 61 |
# File 'lib/ceml/confluence.rb', line 59 def live_with?(candidate) launched? and cast_with?(candidate) end |
#over? ⇒ Boolean
51 52 53 |
# File 'lib/ceml/confluence.rb', line 51 def over? @roles_to_cast.any?{ |r| r.over?(star) } end |
#push(candidate) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ceml/confluence.rb', line 40 def push candidate best_role = best_role_for(candidate) candidate[:roles] = best_role.name.to_sym best_role.casted << candidate @star ||= candidate end |
#rm(*candidates) ⇒ Object
16 17 18 |
# File 'lib/ceml/confluence.rb', line 16 def rm *candidates @roles_to_cast.each{ |role| role.rm *candidates } end |
#stage_with_candidate(candidate) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ceml/confluence.rb', line 26 def stage_with_candidate candidate if cast_with?(candidate) puts "CEML: CAST WITH" return :inside end best_role = best_role_for(candidate) puts "CEML: MADE THRU: #{best_role.inspect}" return :uninterested unless best_role return :joinable if launched? other_roles = @roles_to_cast - [best_role] return :launchable if best_role.one_left? and other_roles.all?(&:filled?) return :listable end |