Class: VertxRedis::Response

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb

Overview

The response received from the REDIS server. Redis responses can have several representations:
  • simple string - C string
  • integer - 64bit integer value
  • bulk - byte array
  • multi - list
Due to the dynamic nature the response object will try to cast the received response to the desired type. A special case should be noted that multi responses are also handled by the response object as it implements the iterable interface. So in this case constructs like for loops on the response will give you access to the underlying elements.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 29

def @@j_api_type.accept?(obj)
  obj.class == Response
end

+ (Object) j_api_type


38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 38

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 41

def self.j_class
  Java::IoVertxRedisClient::Response.java_class
end

+ (Object) unwrap(obj)


35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 35

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)


32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 32

def @@j_api_type.wrap(obj)
  Response.new(obj)
end

Instance Method Details

- (::VertxRedis::Response) get(index) - (::VertxRedis::Response) get(key)

Get this multi response value at a string key. Note that REDIS does not support strings as keys but by convention it encodes hashes in lists where index i is the key, and index i+1 is the value.

Overloads:

Returns:

Raises:

  • (ArgumentError)

115
116
117
118
119
120
121
122
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 115

def get(param_1=nil)
  if param_1.class == Fixnum && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:get, [Java::int.java_class]).call(param_1),::VertxRedis::Response)
  elsif param_1.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(param_1),::VertxRedis::Response)
  end
  raise ArgumentError, "Invalid arguments when calling get(#{param_1})"
end

- (Set<String>) get_keys

Get this multi response keys from a hash. Note that REDIS does not support strings as keys but by convention it encodes hashes in lists where index i is the key, and index i+1 is the value.

Returns:

  • (Set<String>)
    the set of keys.

Raises:

  • (ArgumentError)

126
127
128
129
130
131
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 126

def get_keys
  if !block_given?
    return ::Vertx::Util::Utils.to_set(@j_del.java_method(:getKeys, []).call()).map! { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling get_keys()"
end

- (Fixnum) size

Get this size of this multi response.

Returns:

  • (Fixnum)
    the size of the multi.

Raises:

  • (ArgumentError)

134
135
136
137
138
139
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 134

def size
  if !block_given?
    return @j_del.java_method(:size, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling size()"
end

- (true, false) to_boolean?

Get this response as a Boolean.

Returns:

  • (true, false)
    boolean value.

Raises:

  • (ArgumentError)

94
95
96
97
98
99
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 94

def to_boolean?
  if !block_given?
    return @j_del.java_method(:toBoolean, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling to_boolean?()"
end

- (::Vertx::Buffer) to_buffer

Get this response as Buffer.

Returns:

Raises:

  • (ArgumentError)

102
103
104
105
106
107
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 102

def to_buffer
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:toBuffer, []).call(),::Vertx::Buffer)
  end
  raise ArgumentError, "Invalid arguments when calling to_buffer()"
end

- (Fixnum) to_byte

Get this response as a Byte.

Returns:

  • (Fixnum)
    byte value.

Raises:

  • (ArgumentError)

86
87
88
89
90
91
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 86

def to_byte
  if !block_given?
    return @j_del.java_method(:toByte, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling to_byte()"
end

- (Fixnum) to_integer

Get this response as a Integer.

Returns:

  • (Fixnum)
    int value.

Raises:

  • (ArgumentError)

70
71
72
73
74
75
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 70

def to_integer
  if !block_given?
    return @j_del.java_method(:toInteger, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling to_integer()"
end

- (Fixnum) to_long

Get this response as a Long.

Returns:

  • (Fixnum)
    long value.

Raises:

  • (ArgumentError)

62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 62

def to_long
  if !block_given?
    return @j_del.java_method(:toLong, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling to_long()"
end

- (Fixnum) to_short

Get this response as a Short.

Returns:

  • (Fixnum)
    short value.

Raises:

  • (ArgumentError)

78
79
80
81
82
83
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 78

def to_short
  if !block_given?
    return @j_del.java_method(:toShort, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling to_short()"
end

- (String) to_string

Get this response as a String.

Returns:

  • (String)
    string value

Raises:

  • (ArgumentError)

54
55
56
57
58
59
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 54

def to_string
  if !block_given?
    return @j_del.java_method(:toString, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling to_string()"
end

- (:SIMPLE, ...) type

The response return type.

Returns:

  • (:SIMPLE, :ERROR, :INTEGER, :BULK, :MULTI)
    the type.

Raises:

  • (ArgumentError)

46
47
48
49
50
51
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-redis/response.rb', line 46

def type
  if !block_given?
    return @j_del.java_method(:type, []).call().name.intern
  end
  raise ArgumentError, "Invalid arguments when calling type()"
end