Class: JDBC::Result
- Inherits:
-
Object
- Object
- JDBC::Result
- Defined in:
- lib/jdbc/result.rb
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
- #each_hash ⇒ Object
- #fetch ⇒ Object
- #fetch_hash ⇒ Object
-
#initialize(resultSet, statement) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(resultSet, statement) ⇒ Result
Returns a new instance of Result.
3 4 5 6 7 |
# File 'lib/jdbc/result.rb', line 3 def initialize(resultSet, statement) @rs = resultSet @stmt = statement @columns = end |
Instance Method Details
#close ⇒ Object
53 54 55 56 |
# File 'lib/jdbc/result.rb', line 53 def close @rs.close unless @rs.nil? @stmt.close unless @stmt.nil? end |
#each ⇒ Object
41 42 43 44 45 |
# File 'lib/jdbc/result.rb', line 41 def each while(result = fetch) yield(result) end end |
#each_hash ⇒ Object
47 48 49 50 51 |
# File 'lib/jdbc/result.rb', line 47 def each_hash while(result = fetch_hash) yield(result) end end |
#fetch ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jdbc/result.rb', line 9 def fetch if @rs.next result = [] @columns.each do |column| result << fetch_and_cast(@rs, column) end return result end close return nil end |
#fetch_hash ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jdbc/result.rb', line 25 def fetch_hash if @rs.next result = {} @columns.each do |column| result[column[:name]] = fetch_and_cast(@rs, column) end return result end close return nil end |