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



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

def limit
  @limit
end

#nfailedObject

Returns the value of attribute nfailed

Returns:

  • (Object)

    the current value of nfailed



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

def nfailed
  @nfailed
end

#npassedObject

Returns the value of attribute npassed

Returns:

  • (Object)

    the current value of npassed



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

def npassed
  @npassed
end

#passed_eventsObject

Returns the value of attribute passed_events

Returns:

  • (Object)

    the current value of passed_events



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

def passed_events
  @passed_events
end

#runtimeObject

Returns the value of attribute runtime

Returns:

  • (Object)

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

#hitrateObject



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

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

#limit_reachObject



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

def limit_reach; passed_events.size ;end

#maturity_tripleObject



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

#ntotalObject



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

Returns:

  • (Boolean)


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

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

#summary_textObject



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

def summary_text
  ""
end