Class: VistaRPC4r::RPCResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/vistarpc4r/rpc_response.rb

Overview

Response object from RPC call

type = one of the constant types
value = String or Array of Strings representing the actual response

Constant Summary collapse

SINGLE_VALUE =

Single string response

1
GLOBAL_INSTANCE =

Not sure, but is usually a string response

2
ARRAY =

Array of string response

3
GLOBAL_ARRAY =

Array of string response

4
WORD_PROCESSING =

Array of string response

5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil, type = nil) ⇒ RPCResponse

Returns a new instance of RPCResponse.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vistarpc4r/rpc_response.rb', line 20

def initialize(value=nil, type=nil)
  if value.nil?
    @type = SINGLE_VALUE
    @value = nil
  elsif value.class == String
    @value = value
    @type = SINGLE_VALUE
  elsif value.class == Array
  @value = value
    @type = ARRAY
  elsif !type.nil?
    @value = value
    @type = type
  end
  @error_message = nil
end

Instance Attribute Details

#error_messageObject

Returns the value of attribute error_message.



7
8
9
# File 'lib/vistarpc4r/rpc_response.rb', line 7

def error_message
  @error_message
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/vistarpc4r/rpc_response.rb', line 7

def type
  @type
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/vistarpc4r/rpc_response.rb', line 7

def value
  @value
end

Instance Method Details

#to_sObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vistarpc4r/rpc_response.rb', line 37

def to_s
  sb = String.new
  if !@error_message.nil?
    sb << "ERROR: "
    sb << @error_message
  elsif @value.nil?
    sb << "No value or error"
  elsif @value.class == Array 
    sb = "ARRAY:" + value.join("|")
  elsif @value.class == String
    sb = "STRING:" + value.to_s
  else 
    sb << "Unknown value type"
  end
  return sb
end