Class: Sybase::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/sybase/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, str) ⇒ Command

Returns a new instance of Command.



4
5
6
7
8
9
10
11
# File 'lib/sybase/command.rb', line 4

def initialize(connection, str)
  FFI::MemoryPointer.new(:pointer) do |ptr|
    Lib.check Lib.ct_cmd_alloc(connection, ptr), "ct_cmd_alloc"
    @ptr = FFI::AutoPointer.new(ptr.read_pointer, Lib.method(:ct_cmd_drop))
  end

  @str = str.to_s
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
# File 'lib/sybase/command.rb', line 13

def execute
  set_command
  send
  results
ensure
  finish
end

#finishObject



21
22
23
24
# File 'lib/sybase/command.rb', line 21

def finish
  to_ptr.free
  @ptr = nil
end

#to_ptrObject



26
27
28
# File 'lib/sybase/command.rb', line 26

def to_ptr
  @ptr or raise "command #{self} already ran or was not initialized"
end