Class: SQLAnywhere::DataValue

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/data_value.rb

Instance Method Summary collapse

Instance Method Details

#inspectObject



14
15
16
# File 'lib/data_value.rb', line 14

def inspect
  "<#{self.class} value: #{self.value}, buffer_size: #{self[:buffer_size]}, is_null: #{self.is_null?}, length: #{self.length}, type: #{self[:type]}, buffer: #{self[:buffer]}, length_pointer: #{self[:length]}>"
end

#is_null?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/data_value.rb', line 19

def is_null?
  return nil if self[:is_null].null?
  self[:is_null].read_uint == 1
end

#lengthObject



24
25
26
27
# File 'lib/data_value.rb', line 24

def length
  return nil if self[:length].null?
  self[:length].read_uint
end

#valueObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/data_value.rb', line 29

def value
  return nil if is_null?

  case self[:type]
  #when :invalid_type
  when :binary, :string
    self[:buffer].get_string(0, length)
  when :double
    self[:buffer].read_double
  when :val64 # 64 bit integer
    self[:buffer].read_long_long
  when :unsigned_val64 # 64 bit unsigned integer
    self[:buffer].read_ulong_long
  when :val32
    self[:buffer].read_int
  when :unsigned_val32
    self[:buffer].read_uint
  when :val16
    self[:buffer].read_short
  when :unsigned_val16
    self[:buffer].read_ushort
  when :val8
    self[:buffer].read_char
  when :unsigned_val8
    self[:buffer].read_uchar
  else
    raise "Type not yet implemented #{self[:type]}"
  end

end