Class: Tarantool::Requests::Select

Inherits:
Tarantool::Request show all
Defined in:
lib/tarantool/requests/select.rb

Instance Attribute Summary collapse

Attributes inherited from Tarantool::Request

#args, #params, #space, #space_no

Instance Method Summary collapse

Methods inherited from Tarantool::Request

#connection, #initialize, #make_packet, #make_response, pack_field, pack_tuple, #perform, #request_id, request_type, #response_params

Constructor Details

This class inherits a constructor from Tarantool::Request

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/tarantool/requests/select.rb', line 6

def count
  @count
end

#index_noObject (readonly)

Returns the value of attribute index_no.



6
7
8
# File 'lib/tarantool/requests/select.rb', line 6

def index_no
  @index_no
end

#limitObject (readonly)

Returns the value of attribute limit.



6
7
8
# File 'lib/tarantool/requests/select.rb', line 6

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



6
7
8
# File 'lib/tarantool/requests/select.rb', line 6

def offset
  @offset
end

#tuplesObject (readonly)

Returns the value of attribute tuples.



6
7
8
# File 'lib/tarantool/requests/select.rb', line 6

def tuples
  @tuples
end

Instance Method Details

#make_bodyObject



16
17
18
19
# File 'lib/tarantool/requests/select.rb', line 16

def make_body
  [space_no, index_no, offset, limit, tuples.size].pack('LLLLL') +
  tuples.map { |tuple| self.class.pack_tuple(*tuple) }.join
end

#parse_argsObject

Raises:



7
8
9
10
11
12
13
14
# File 'lib/tarantool/requests/select.rb', line 7

def parse_args
  @index_no = params[:index_no] || 0
  @offset = params[:offset] || 0
  @limit = params[:limit] || -1
  @tuples = params[:values] || args
  raise(ArgumentError.new('values are required')) if tuples.empty?
  params[:return_tuple] = true
end