Class: ApimaticCalculator::SimpleCalculatorController
- Inherits:
-
BaseController
- Object
- BaseController
- ApimaticCalculator::SimpleCalculatorController
- Defined in:
- lib/apimatic_calculator/controllers/simple_calculator_controller.rb
Overview
SimpleCalculatorController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#calculate(operation, x, y) ⇒ Float
Calculates the expression using the specified operation.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from ApimaticCalculator::BaseController
Instance Method Details
#calculate(operation, x, y) ⇒ Float
Calculates the expression using the specified operation. apply on the variables
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/apimatic_calculator/controllers/simple_calculator_controller.rb', line 15 def calculate(operation, x, y) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/{operation}', Server::DEFAULT) .template_param(new_parameter(operation, key: 'operation') .should_encode(true)) .query_param(new_parameter(x, key: 'x')) .query_param(new_parameter(y, key: 'y')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:deserialize_primitive_types)) .deserialize_into(proc do |response| response.to_f end) .is_primitive_response(true)) .execute end |