Sha256: c8d0ed8a43e69cf9e7299890111d3ecad83471c44c6bbd5448825b1598528f10
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require 'base64' require 'cgi' class OEHClient::Interaction::Optimization # HASH keys based on the response data OPT_RESPONSE_DATA = "data" OPT_RESPONSE_PATH = "path" OPT_RESPONSE_ID = "responseId" OPT_RESPONSE_MIME_TYPE = "dataMimeType" OPT_RESPONSE_DIRECTIVES = "directives" # Localized attributes equivalent to the returned Hash object in the response attr_accessor :data, # Base64 Encoded Asset returned by OEH :path, # The path of the optimization based on the OEH Configuration :response_id, # The Response ID of the asset based on the OEH Configuration :mime_type, # The MIME Type of the asset based on the OEH Configuration :directives # ---- Class Methods def self.create(properties={}) # create a new instance of the OEHClient::Interaction::Optimization class optimization_instance = OEHClient::Interaction::Optimization.new() # assign all data attributes based on the properties object that is passed optimization_instance.data = properties[OPT_RESPONSE_DATA] if (properties.has_key?(OPT_RESPONSE_DATA)) optimization_instance.path = properties[OPT_RESPONSE_PATH] if (properties.has_key?(OPT_RESPONSE_PATH)) optimization_instance.response_id = properties[OPT_RESPONSE_ID] if (properties.has_key?(OPT_RESPONSE_ID)) optimization_instance.mime_type = properties[OPT_RESPONSE_MIME_TYPE] if (properties.has_key?(OPT_RESPONSE_ID)) optimization_instance.directives = properties[OPT_RESPONSE_DIRECTIVES] if (properties.has_key?(OPT_RESPONSE_DIRECTIVES)) #return the new instance of the optimzation class optimization_instance end # ---- Instance Methods # TODO: Need to create a series of methods that properly decodes the object based on Mime Type # decodes the Base64 encoded data and returns it raw form def decode_data() CGI.unescapeHTML(Base64.decode64(@data.to_json)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oeh-client-0.1.0 | lib/oehclient/interaction/optimization.rb |