Class: OEHClient::Realtime::Optimization
- Inherits:
-
Object
- Object
- OEHClient::Realtime::Optimization
- Defined in:
- lib/oehclient/realtime/optimization.rb
Constant Summary collapse
- OPT_RESPONSE_NAME =
HASH keys based on the response data
"name"
- OPT_RESPONSE_ASSET =
"asset"
- OPT_RESPONSE_CONTENT =
"content"
- OPT_RESPONSE_CONTENT_URL =
"contentUrl"
- OPT_RESPONSE_MIME_TYPE =
"mimeType"
- OPT_RESPONSE_PROPOSITION =
"proposition"
- OPT_RESPONSE_RESPONSES =
"responses"
Instance Attribute Summary collapse
-
#content ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#content_url ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#interaction ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#mime_type ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#name ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#proposition ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
-
#responses ⇒ Object
Localized attributes equivalent to the returned Hash object in the response.
Class Method Summary collapse
-
.create(interaction, properties = {}) ⇒ Object
—- Class Methods.
Instance Attribute Details
permalink #content ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def content @content end |
permalink #content_url ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def content_url @content_url end |
permalink #interaction ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def interaction @interaction end |
permalink #mime_type ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def mime_type @mime_type end |
permalink #name ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def name @name end |
permalink #proposition ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def proposition @proposition end |
permalink #responses ⇒ Object
Localized attributes equivalent to the returned Hash object in the response
16 17 18 |
# File 'lib/oehclient/realtime/optimization.rb', line 16 def responses @responses end |
Class Method Details
permalink .create(interaction, properties = {}) ⇒ Object
—- Class Methods
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/oehclient/realtime/optimization.rb', line 26 def self.create(interaction, properties={}) one_asset = properties[OPT_RESPONSE_ASSET] # create a new instance of the OEHClient::Realtime::Optimization class optimization_instance = OEHClient::Realtime::Optimization.new() # assign all data attributes based on the properties object that is passed optimization_instance.name = properties[OPT_RESPONSE_NAME] if (properties.has_key?(OPT_RESPONSE_NAME)) optimization_instance.proposition = properties[OPT_RESPONSE_PROPOSITION] if (properties.has_key?(OPT_RESPONSE_PROPOSITION)) # map the asset data to the class instance variables optimization_instance.content = CGI.unescapeHTML(one_asset[OPT_RESPONSE_CONTENT]) if (one_asset.has_key?(OPT_RESPONSE_CONTENT)) optimization_instance.content_url = one_asset[OPT_RESPONSE_CONTENT_URL] if (one_asset.has_key?(OPT_RESPONSE_CONTENT_URL)) optimization_instance.mime_type = one_asset[OPT_RESPONSE_MIME_TYPE] if (one_asset.has_key?(OPT_RESPONSE_MIME_TYPE)) # map each of the respones to the response object optimization_instance.responses ||= Array.new one_asset[OPT_RESPONSE_RESPONSES].each do | asset_response | optimization_instance.responses << OEHClient::Realtime::Response.create(optimization_instance, asset_response) end # set the parent interaction object optimization_instance.interaction = interaction #return the new instance of the optimzation class optimization_instance end |