Method: Calculator#sum

Defined in:
src/ruby/bin/math_server.rb

#sum(call) ⇒ Object



109
110
111
112
113
114
# File 'src/ruby/bin/math_server.rb', line 109

def sum(call)
  # the requests are accesible as the Enumerator call#each_request
  nums = call.each_remote_read.collect(&:num)
  sum = nums.inject { |s, x| s + x }
  Math::Num.new(num: sum)
end