Module: Rubeus::Extensions::Java::Sql::ResultSet

Includes:
Enumerable
Defined in:
lib/rubeus/extensions/java/sql/result_set.rb

Instance Method Summary collapse

Instance Method Details

#each(&block) ⇒ Object



7
8
9
10
# File 'lib/rubeus/extensions/java/sql/result_set.rb', line 7

def each(&block)
  return unless block_given?
  yield(self) while self.next
end

#each_arrayObject



12
13
14
# File 'lib/rubeus/extensions/java/sql/result_set.rb', line 12

def each_array
  each{|rs| yield(rs.to_a)}
end

#each_hashObject



16
17
18
# File 'lib/rubeus/extensions/java/sql/result_set.rb', line 16

def each_hash
  each{|rs| yield(rs.to_hash)}
end

#to_a(default_value = nil) ⇒ Object



20
21
22
# File 'lib/rubeus/extensions/java/sql/result_set.rb', line 20

def to_a(default_value = nil)
  .map{|i| get_object(i) || default_value}
end

#to_hashObject



24
25
26
27
28
29
30
# File 'lib/rubeus/extensions/java/sql/result_set.rb', line 24

def to_hash
  column_names = .column_names
  .inject({}) do |dest, i|
    dest[column_names[i]] = get_object(i)
    dest
  end
end