Class: Jeka::Analysis::Implementation

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/jeka/analysis/implementation.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Raises:

  • (NoMethodError)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jeka/analysis/implementation.rb', line 14

def method_missing(method, *args)
  if method =~ /^average_/
    r = (/^average_(.*)/.match(method))[1].to_sym
    avg = 0
    i = 0
    self.results.each do |result|
      avg += result.send(r)
      i += 1
    end
    return avg/i
  end
  raise NoMethodError
end