Class: PostgresPR::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/postgres-pr/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(fields, rows, cmd_tag) ⇒ Result

Returns a new instance of Result.



2
3
4
5
6
# File 'lib/postgres-pr/result.rb', line 2

def initialize(fields, rows, cmd_tag)
  @fields = fields
  @rows = rows
  @cmd_tag = cmd_tag
end

Instance Method Details

#clearObject

free the result set



29
30
31
# File 'lib/postgres-pr/result.rb', line 29

def clear
  @fields = @rows = @cmd_tag = nil
end

#cmd_tuplesObject

Returns the number of rows affected by the SQL command



34
35
36
37
38
39
# File 'lib/postgres-pr/result.rb', line 34

def cmd_tuples
  case @cmd_tag
  when /^INSERT\s+(\d+)\s+(\d+)$/, /^(DELETE|UPDATE|MOVE|FETCH)\s+(\d+)$/
    $2.to_i
  end
end

#fname(index) ⇒ Object



16
17
18
# File 'lib/postgres-pr/result.rb', line 16

def fname(index)
  @fields[index].name
end

#ftype(index) ⇒ Object



20
21
22
# File 'lib/postgres-pr/result.rb', line 20

def ftype(index)
  @fields[index].type_oid
end

#getvalue(tup_num, field_num) ⇒ Object



24
25
26
# File 'lib/postgres-pr/result.rb', line 24

def getvalue(tup_num, field_num)
  @rows[tup_num][field_num]
end

#nfieldsObject



12
13
14
# File 'lib/postgres-pr/result.rb', line 12

def nfields
  @fields.size
end

#ntuplesObject



8
9
10
# File 'lib/postgres-pr/result.rb', line 8

def ntuples
  @rows.size
end