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
103 104 105 |
# File 'lib/ankit/challenge.rb', line 103 def limit @limit end |
#nfailed ⇒ Object
Returns the value of attribute nfailed
103 104 105 |
# File 'lib/ankit/challenge.rb', line 103 def nfailed @nfailed end |
#npassed ⇒ Object
Returns the value of attribute npassed
103 104 105 |
# File 'lib/ankit/challenge.rb', line 103 def npassed @npassed end |
#passed_events ⇒ Object
Returns the value of attribute passed_events
103 104 105 |
# File 'lib/ankit/challenge.rb', line 103 def passed_events @passed_events end |
#runtime ⇒ Object
Returns the value of attribute runtime
103 104 105 |
# File 'lib/ankit/challenge.rb', line 103 def runtime @runtime end |
Class Method Details
.make(runtime, limit) ⇒ Object
104 105 106 |
# File 'lib/ankit/challenge.rb', line 104 def self.make(runtime, limit) self.new(runtime, limit, 0, 0, {}) end |
Instance Method Details
#failed_on(event) ⇒ Object
117 118 119 |
# File 'lib/ankit/challenge.rb', line 117 def failed_on(event) self.nfailed += 1 end |
#hitrate ⇒ Object
131 |
# File 'lib/ankit/challenge.rb', line 131 def hitrate; 0 < ntotal ? npassed.to_f/ntotal : 0; end |
#limit_reach ⇒ Object
129 |
# File 'lib/ankit/challenge.rb', line 129 def limit_reach; passed_events.size ;end |
#maturity_triple ⇒ Object
121 122 123 124 125 126 |
# File 'lib/ankit/challenge.rb', line 121 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
130 |
# File 'lib/ankit/challenge.rb', line 130 def ntotal; npassed + nfailed; end |
#passed_on(event) ⇒ Object
112 113 114 115 |
# File 'lib/ankit/challenge.rb', line 112 def passed_on(event) self.passed_events[event.name] = event self.npassed += 1 end |
#reached_limit? ⇒ Boolean
128 |
# File 'lib/ankit/challenge.rb', line 128 def reached_limit?; limit <= passed_events.size; end |
#summary_text ⇒ Object
108 109 110 |
# File 'lib/ankit/challenge.rb', line 108 def summary_text "" end |