Class: DTK::Client::Execute::Command::APICall::PreviousResponse
- Inherits:
-
TranslationTerm::Param
- Object
- TranslationTerm
- TranslationTerm::Param
- DTK::Client::Execute::Command::APICall::PreviousResponse
- Defined in:
- lib/execute/command/api_call/translation_term.rb
Instance Method Summary collapse
-
#initialize(response_key) ⇒ PreviousResponse
constructor
A new instance of PreviousResponse.
- #translate(key, api_params, opts = {}) ⇒ Object
Methods inherited from TranslationTerm
#instance_form, instance_form, matches?
Constructor Details
#initialize(response_key) ⇒ PreviousResponse
Returns a new instance of PreviousResponse.
104 105 106 |
# File 'lib/execute/command/api_call/translation_term.rb', line 104 def initialize(response_key) @response_key = response_key end |
Instance Method Details
#translate(key, api_params, opts = {}) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/execute/command/api_call/translation_term.rb', line 107 def translate(key,api_params,opts={}) unless last_result = opts[:last_result] raise ErrorUsage.new("PreviousResponse used before results computed") end match = nil unless matching_key = [@response_key.to_s,@response_key.to_sym].find{|k|last_result.has_key?(k)} raise ErrorUsage.new("Key #{@response_key} in PreviousResponse not found in last results (#{last_result.inspect})") end last_result[matching_key] end |