Class: Informix::SequentialCursor

Inherits:
CursorBase show all
Includes:
Enumerable
Defined in:
lib/informix/seqcursor.rb,
ext/informixc.c

Direct Known Subclasses

ScrollCursor

Instance Method Summary collapse

Methods inherited from CursorBase

#close, #free, #id, #open

Instance Method Details

#each(&block) ⇒ Object

Iterates over the remaining records, passing each record to the block as an array.

Returns __self__.

cursor.each {|record| block } => cursor


115
116
117
# File 'lib/informix/seqcursor.rb', line 115

def each(&block)
  each0(Array, false, &block)
end

#each!(&block) ⇒ Object

Iterates over the remaining records, passing each record to the block as an array. No new Array objects are created for each record. The same Array object is reused in each call.

Returns __self__.

cursor.each! {|record| block } => cursor


126
127
128
# File 'lib/informix/seqcursor.rb', line 126

def each!(&block)
  each0(Array, true, &block)
end

#each_by(n, &block) ⇒ Object

Iterates over the remaining records, passing at most n records to the block as arrays.

Returns __self__.

cursor.each_by(n) {|records| block } => cursor


155
156
157
# File 'lib/informix/seqcursor.rb', line 155

def each_by(n, &block)
  each_by0(n, Array, &block)
end

#each_hash(&block) ⇒ Object

Iterates over the remaining records, passing each record to the block as a hash.

cursor.each_hash {|record| block } => cursor


134
135
136
# File 'lib/informix/seqcursor.rb', line 134

def each_hash(&block)
  each0(Hash, false, &block)
end

#each_hash!(&block) ⇒ Object

Iterates over the remaining records, passing each record to the block as a hash. No new Hash objects are created for each record. The same Hash object is reused in each call.

Returns __self__.

cursor.each_hash! {|record| block } => cursor


145
146
147
# File 'lib/informix/seqcursor.rb', line 145

def each_hash!(&block)
  each0(Hash, true, &block)
end

#each_hash_by(n, &block) ⇒ Object

Iterates over the remaining records, passing at most n records to the block as hashes.

Returns __self__.

cursor.each_hash_by(n) {|records| block } => cursor


165
166
167
# File 'lib/informix/seqcursor.rb', line 165

def each_hash_by(n, &block)
  each_by0(n, Hash, &block)
end

#fetchObject

Fetches the next record.

Returns the record fetched as an array, or nil if there are no records left.

cursor.fetch  => array or nil


42
43
44
# File 'lib/informix/seqcursor.rb', line 42

def fetch
  fetch0(Array, false)
end

#fetch!Object

Fetches the next record, storing it in the same Array object every time it is called.

Returns the record fetched as an array, or nil if there are no records left.

cursor.fetch!  => array or nil


53
54
55
# File 'lib/informix/seqcursor.rb', line 53

def fetch!
  fetch0(Array, true)
end

#fetch_allObject

Returns all the records left as an array of arrays

cursor.fetch_all  => array


98
99
100
# File 'lib/informix/seqcursor.rb', line 98

def fetch_all
  fetch_many0(nil, Array)
end

#fetch_hashObject

Fetches the next record.

Returns the record fetched as a hash, or nil if there are no records left.

cursor.fetch_hash  => hash or nil


63
64
65
# File 'lib/informix/seqcursor.rb', line 63

def fetch_hash
  fetch0(Hash, false)
end

#fetch_hash!Object

Fetches the next record, storing it in the same Hash object every time it is called.

Returns the record fetched as a hash, or nil if there are no records left.

cursor.fetch_hash!  => hash or nil


74
75
76
# File 'lib/informix/seqcursor.rb', line 74

def fetch_hash!
  fetch0(Hash, true)
end

#fetch_hash_allObject

Returns all the records left as an array of hashes

cursor.fetch_hash_all  => array


105
106
107
# File 'lib/informix/seqcursor.rb', line 105

def fetch_hash_all
  fetch_many0(nil, Hash)
end

#fetch_hash_many(n) ⇒ Object

Reads at most n records. Returns the records read as an array of hashes.

cursor.fetch_hash_many(n)  => array


91
92
93
# File 'lib/informix/seqcursor.rb', line 91

def fetch_hash_many(n)
  fetch_many0(n, Hash)
end

#fetch_many(n) ⇒ Object

Reads at most n records.

Returns the records read as an array of arrays

cursor.fetch_many(n)  => array


83
84
85
# File 'lib/informix/seqcursor.rb', line 83

def fetch_many(n)
  fetch_many0(n, Array)
end