Class: OEHClient::Realtime::Response
- Inherits:
-
Object
- Object
- OEHClient::Realtime::Response
- Defined in:
- lib/oehclient/realtime/response.rb
Constant Summary collapse
- OPT_RESPONSE_CODE =
HASH keys based on the response data
"code"
- OPT_RESPONSE_SENTIMENT =
"sentiment"
- OPT_RESPONSE_LABEL =
"label"
- OPT_RESPONSE_IMAGE_URL =
"imageUrl"
- OPT_RESPONSE_TARGET_URL =
"targetUrl"
- OPT_RESPONSE_TARGET =
"target"
- RESPONSE_CODE_PROPERTY =
"_RESP_CODE_"
- SENTIMENT_POSITIVE =
"positive"
- SENTIMENT_NEUTRAL =
"neutral"
- SENTIMENT_NEGATIVE =
"negative"
Instance Attribute Summary collapse
-
#code ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#image_url ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#label ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#optimization ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#sentiment ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#target ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#target_url ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
Class Method Summary collapse
-
.create(optimization, properties = {}) ⇒ Object
—- Class Methods.
Instance Method Summary collapse
-
#interaction ⇒ Object
helper method to get the interacton object from the parent optimization.
-
#is_negative? ⇒ Boolean
returns true if the current response is a negative response.
-
#is_neutral? ⇒ Boolean
returns true if the current response is a neutral response.
-
#is_positive? ⇒ Boolean
returns true if the curent response is a positive response.
-
#send ⇒ Object
wrapper for sending the response from the existing object.
Instance Attribute Details
permalink #code ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def code @code end |
permalink #image_url ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def image_url @image_url end |
permalink #label ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def label @label end |
permalink #optimization ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def optimization @optimization end |
permalink #sentiment ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def sentiment @sentiment end |
permalink #target ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def target @target end |
permalink #target_url ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
19 20 21 |
# File 'lib/oehclient/realtime/response.rb', line 19 def target_url @target_url end |
Class Method Details
permalink .create(optimization, properties = {}) ⇒ Object
—- Class Methods
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/oehclient/realtime/response.rb', line 29 def self.create(optimization, properties={}) # create a new instance of the OEHClient::Realtime::Optimization class response_instance = OEHClient::Realtime::Response.new() # assign all data attributes based on the properties object that is passed response_instance.code = properties[OPT_RESPONSE_CODE] if (properties.has_key?(OPT_RESPONSE_CODE)) response_instance.sentiment = properties[OPT_RESPONSE_SENTIMENT] if (properties.has_key?(OPT_RESPONSE_SENTIMENT)) response_instance.label = properties[OPT_RESPONSE_LABEL] if (properties.has_key?(OPT_RESPONSE_LABEL)) response_instance.image_url = properties[OPT_RESPONSE_IMAGE_URL] if (properties.has_key?(OPT_RESPONSE_IMAGE_URL)) response_instance.target_url = properties[OPT_RESPONSE_TARGET_URL] if (properties.has_key?(OPT_RESPONSE_TARGET_URL)) response_instance.target = properties[OPT_RESPONSE_TARGET] if (properties.has_key?(OPT_RESPONSE_TARGET)) # map the parent object response_instance.optimization = optimization #return the new instance of the optimization class response_instance end |
Instance Method Details
permalink #interaction ⇒ Object
helper method to get the interacton object from the parent optimization
51 52 53 |
# File 'lib/oehclient/realtime/response.rb', line 51 def interaction @optimization.interaction end |
permalink #is_negative? ⇒ Boolean
returns true if the current response is a negative response
69 70 71 |
# File 'lib/oehclient/realtime/response.rb', line 69 def is_negative? ( @sentiment.casecmp(SENTIMENT_NEGATIVE) == 0) end |
permalink #is_neutral? ⇒ Boolean
returns true if the current response is a neutral response
65 66 67 |
# File 'lib/oehclient/realtime/response.rb', line 65 def is_neutral?() ( @sentiment.casecmp(SENTIMENT_NEUTRAL) == 0) end |
permalink #is_positive? ⇒ Boolean
returns true if the curent response is a positive response
61 62 63 |
# File 'lib/oehclient/realtime/response.rb', line 61 def is_positive?() (@sentiment.casecmp(SENTIMENT_POSITIVE) == 0) end |
permalink #send ⇒ Object
wrapper for sending the response from the existing object
56 57 58 |
# File 'lib/oehclient/realtime/response.rb', line 56 def send interaction.send_update({RESPONSE_CODE_PROPERTY => @code}) end |