class OEHClient::Realtime::Response

Constants

OPT_RESPONSE_CODE

HASH keys based on the response data

OPT_RESPONSE_IMAGE_URL
OPT_RESPONSE_LABEL
OPT_RESPONSE_SENTIMENT
OPT_RESPONSE_TARGET
OPT_RESPONSE_TARGET_URL
RESPONSE_CODE_PROPERTY
SENTIMENT_NEGATIVE
SENTIMENT_NEUTRAL
SENTIMENT_POSITIVE

Attributes

code[RW]

Localized attributes equivalent to the returned Hash object in the response

image_url[RW]

Localized attributes equivalent to the returned Hash object in the response

label[RW]

Localized attributes equivalent to the returned Hash object in the response

optimization[RW]

Localized attributes equivalent to the returned Hash object in the response

sentiment[RW]

Localized attributes equivalent to the returned Hash object in the response

target[RW]

Localized attributes equivalent to the returned Hash object in the response

target_url[RW]

Localized attributes equivalent to the returned Hash object in the response

Public Class Methods

create(optimization, properties={}) click to toggle source

—- Class Methods

# 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

Public Instance Methods

interaction() click to toggle source

helper method to get the interacton object from the parent optimization

# File lib/oehclient/realtime/response.rb, line 51
def interaction
        @optimization.interaction
end
is_negative?() click to toggle source

returns true if the current response is a negative response

# File lib/oehclient/realtime/response.rb, line 69
def is_negative?
        ( @sentiment.casecmp(SENTIMENT_NEGATIVE) == 0)
end
is_neutral?() click to toggle source

returns true if the current response is a neutral response

# File lib/oehclient/realtime/response.rb, line 65
def is_neutral?()
        ( @sentiment.casecmp(SENTIMENT_NEUTRAL) == 0)
end
is_positive?() click to toggle source

returns true if the curent response is a positive response

# File lib/oehclient/realtime/response.rb, line 61
def is_positive?()
         (@sentiment.casecmp(SENTIMENT_POSITIVE) == 0)
end
send() click to toggle source

wrapper for sending the response from the existing object

# File lib/oehclient/realtime/response.rb, line 56
def send
        interaction.send_update({RESPONSE_CODE_PROPERTY => @code})
end