Class: Syspy::TdsParamfmt2

Inherits:
TdsPackage show all
Defined in:
lib/tds_packages/tds_paramfmt2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TdsPackage

#read_int, #read_int16, #read_int32, #read_text, #read_uint, #read_uint16, #read_uint32

Constructor Details

#initialize(io, length) ⇒ TdsParamfmt2

Returns a new instance of TdsParamfmt2.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tds_packages/tds_paramfmt2.rb', line 8

def initialize(io,length)
  @params_count = read_uint16(io)     
  @parameters = []
 
  1.upto(@params_count){
    parameter = {}
    name_length = read_uint(io)
    parameter[:name_length] = name_length
    if(name_length > 0)
      parameter[:param_name] = read_text(io,name_length)
    end
    parameter[:status] = read_uint32(io)
    parameter[:user_type] = read_int32(io)
    data_type = read_uint(io)
    parameter[:data_type] = data_type        

    data_length = TdsTypes.fixed_length(data_type)         

    case data_length
      when -5
        data_length = Bytes.int32le(io)
      when -4
        data_length = Bytes.int32le(io)
      when -2
        data_length = Bytes.int32le(io)
      when -1
        data_length = Bytes.uint(io) 
    end       
    
    parameter[:length] = data_length

    if(TdsTypes.numeric?(data_type))
      parameter[:precision] = read_uint(io)
      parameter[:scale] = read_uint(io)
    end

    locale_length = read_uint(io)
    parameter[:locale_length] = locale_length
    if(locale_length > 0)
      parameter[:locale_info] = read_text(io,locale_length)
    end       
    @parameters << parameter
  }     
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



6
7
8
# File 'lib/tds_packages/tds_paramfmt2.rb', line 6

def parameters
  @parameters
end

#params_countObject (readonly)

Returns the value of attribute params_count.



6
7
8
# File 'lib/tds_packages/tds_paramfmt2.rb', line 6

def params_count
  @params_count
end