Class: PostgresPR::Result
- Inherits:
-
Object
- Object
- PostgresPR::Result
- Defined in:
- lib/postgres-pr/result.rb
Instance Method Summary collapse
-
#clear ⇒ Object
free the result set.
-
#cmd_tuples ⇒ Object
Returns the number of rows affected by the SQL command.
- #fname(index) ⇒ Object
- #ftype(index) ⇒ Object
- #getvalue(tup_num, field_num) ⇒ Object
-
#initialize(fields, rows, cmd_tag) ⇒ Result
constructor
A new instance of Result.
- #nfields ⇒ Object
- #ntuples ⇒ Object
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
#clear ⇒ Object
free the result set
29 30 31 |
# File 'lib/postgres-pr/result.rb', line 29 def clear @fields = @rows = @cmd_tag = nil end |
#cmd_tuples ⇒ Object
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 |
#nfields ⇒ Object
12 13 14 |
# File 'lib/postgres-pr/result.rb', line 12 def nfields @fields.size end |
#ntuples ⇒ Object
8 9 10 |
# File 'lib/postgres-pr/result.rb', line 8 def ntuples @rows.size end |