Class: Ankit::Challenge::Session

Inherits:
Struct
  • Object
show all
Defined in:
lib/ankit/challenge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#limitObject

Returns the value of attribute limit

Returns:

  • (Object)

    the current value of limit



104
105
106
# File 'lib/ankit/challenge.rb', line 104

def limit
  @limit
end

#nfailedObject

Returns the value of attribute nfailed

Returns:

  • (Object)

    the current value of nfailed



104
105
106
# File 'lib/ankit/challenge.rb', line 104

def nfailed
  @nfailed
end

#npassedObject

Returns the value of attribute npassed

Returns:

  • (Object)

    the current value of npassed



104
105
106
# File 'lib/ankit/challenge.rb', line 104

def npassed
  @npassed
end

#passed_eventsObject

Returns the value of attribute passed_events

Returns:

  • (Object)

    the current value of passed_events



104
105
106
# File 'lib/ankit/challenge.rb', line 104

def passed_events
  @passed_events
end

#runtimeObject

Returns the value of attribute runtime

Returns:

  • (Object)

    the current value of 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

#hitrateObject



132
# File 'lib/ankit/challenge.rb', line 132

def hitrate; 0 < ntotal ? npassed.to_f/ntotal : 0; end

#limit_reachObject



130
# File 'lib/ankit/challenge.rb', line 130

def limit_reach; passed_events.size ;end

#maturity_tripleObject



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

#ntotalObject



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

Returns:

  • (Boolean)


129
# File 'lib/ankit/challenge.rb', line 129

def reached_limit?; limit <= passed_events.size; end

#summary_textObject



109
110
111
# File 'lib/ankit/challenge.rb', line 109

def summary_text
  ""
end