Class: Ankit::Challenge::Session
- Inherits:
-
Struct
- Object
- Struct
- Ankit::Challenge::Session
- Defined in:
- lib/ankit/challenge.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#nfailed ⇒ Object
Returns the value of attribute nfailed.
-
#npassed ⇒ Object
Returns the value of attribute npassed.
-
#passed_events ⇒ Object
Returns the value of attribute passed_events.
-
#runtime ⇒ Object
Returns the value of attribute runtime.
Class Method Summary collapse
Instance Method Summary collapse
- #failed_on(event) ⇒ Object
- #hitrate ⇒ Object
- #limit_reach ⇒ Object
- #maturity_triple ⇒ Object
- #ntotal ⇒ Object
- #passed_on(event) ⇒ Object
- #reached_limit? ⇒ Boolean
- #summary_text ⇒ Object
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit
104 105 106 |
# File 'lib/ankit/challenge.rb', line 104 def limit @limit end |
#nfailed ⇒ Object
Returns the value of attribute nfailed
104 105 106 |
# File 'lib/ankit/challenge.rb', line 104 def nfailed @nfailed end |
#npassed ⇒ Object
Returns the value of attribute npassed
104 105 106 |
# File 'lib/ankit/challenge.rb', line 104 def npassed @npassed end |
#passed_events ⇒ Object
Returns the value of attribute passed_events
104 105 106 |
# File 'lib/ankit/challenge.rb', line 104 def passed_events @passed_events end |
#runtime ⇒ Object
Returns the value of attribute runtime
104 105 106 |
# File 'lib/ankit/challenge.rb', line 104 def runtime @runtime end |
Class Method Details
.make(runtime, limit) ⇒ Object
105 106 107 |
# File 'lib/ankit/challenge.rb', line 105 def self.make(runtime, limit) self.new(runtime, limit, 0, 0, {}) end |
Instance Method Details
#failed_on(event) ⇒ Object
118 119 120 |
# File 'lib/ankit/challenge.rb', line 118 def failed_on(event) self.nfailed += 1 end |
#hitrate ⇒ Object
132 |
# File 'lib/ankit/challenge.rb', line 132 def hitrate; 0 < ntotal ? npassed.to_f/ntotal : 0; end |
#limit_reach ⇒ Object
130 |
# File 'lib/ankit/challenge.rb', line 130 def limit_reach; passed_events.size ;end |
#maturity_triple ⇒ Object
122 123 124 125 126 127 |
# File 'lib/ankit/challenge.rb', line 122 def maturity_triple return [0,0,0] if passed_events.empty? mats = passed_events.values.map(&:maturity) avg = mats.inject(0,:+)/mats.size [mats.min, avg, mats.max] end |
#ntotal ⇒ Object
131 |
# File 'lib/ankit/challenge.rb', line 131 def ntotal; npassed + nfailed; end |
#passed_on(event) ⇒ Object
113 114 115 116 |
# File 'lib/ankit/challenge.rb', line 113 def passed_on(event) self.passed_events[event.name] = event self.npassed += 1 end |
#reached_limit? ⇒ Boolean
129 |
# File 'lib/ankit/challenge.rb', line 129 def reached_limit?; limit <= passed_events.size; end |
#summary_text ⇒ Object
109 110 111 |
# File 'lib/ankit/challenge.rb', line 109 def summary_text "" end |