Class: IBRuby::Row

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/src.rb

Overview

This class models a row of data fetched as part of a SQL query.

Instance Method Summary collapse

Constructor Details

#initialize(results, data, number) ⇒ Row

This is the constructor for the Row class. This method shouldn’t really be used as Row objects are automatically created by ResultSets.

Parameters

results

The ResultSet object that the row relates to.

data

An array containing the row data values.

number

The row number for the new row.



868
869
# File 'lib/src.rb', line 868

def initialize(results, data, number)
end

Instance Method Details

#[](index) ⇒ Object

This method fetches the value associated with a column within a Row object.

Parameters

index

Either the offset of the column to retrieve the value of or the alias of the column to retrieve the value of (column alias comparisons are case sensitive).



919
920
# File 'lib/src.rb', line 919

def [](index)
end

#aliasesObject

This method retrieves an array of column aliases for a Row object.



1025
1026
# File 'lib/src.rb', line 1025

def aliases
end

#column_alias(index) ⇒ Object

This method fetches the alias of a column within a row of data.

Parameters

index

The index of the column to fetch the alias for. The first column in the row is at offset zero.



906
907
# File 'lib/src.rb', line 906

def column_alias(index)
end

#column_countObject

This method fetches a count of the number of columns of data that are available from a row.



884
885
# File 'lib/src.rb', line 884

def column_count
end

#column_name(index) ⇒ Object

This method fetches the name of a column within a row of data.

Parameters

index

The index of the column to fetch the name for. The first column in the row is at offset zero.



895
896
# File 'lib/src.rb', line 895

def column_name(index)
end

#each {|column, vlaue| ... } ⇒ Object

This method iterates over the contents of a Row object. The block specified for the method should accept two parameters; one for the column alias and one for the column value.

Yields:

  • (column, vlaue)


928
929
930
# File 'lib/src.rb', line 928

def each
   yield column, vlaue
end

#each_key {|column| ... } ⇒ Object

This method iterates over the column names for a Row class.

Yields:

  • (column)


936
937
938
# File 'lib/src.rb', line 936

def each_key
   yield column
end

#each_value {|value| ... } ⇒ Object

This method iterators over the column values for a Row class.

Yields:

  • (value)


944
945
946
# File 'lib/src.rb', line 944

def each_value
   yield value
end

#fetch(key, alternative = nil) {|key| ... } ⇒ Object

An implementation of the Hash#fetch method for the Row class. The method accepts a block but this should not be specified if a value for the alternative parameter is specified.

Parameters

key

A string containing the column alias to retrieve.

alternative

A reference to the alternative value to be returned if the keyed value is not found. Defaults to nil.

Yields:

  • (key)


959
960
961
# File 'lib/src.rb', line 959

def fetch(key, alternative=nil)
   yield key
end

#get_base_type(index) ⇒ Object

This method retrieves the base SQL type for a column of data within a Row object. The method returns one of the base types defined in the SQLType class but does not return an actual SQLType object.

Parameters

index

The offset from the Row first column of the column to return the type information for.



1082
1083
# File 'lib/src.rb', line 1082

def get_base_type(index)
end

#has_alias?(name) ⇒ Boolean

This method is used to determine whether a Row object contains a given column alias.

Parameters

name

A String containing the column alias to check for.

Returns:

  • (Boolean)


993
994
# File 'lib/src.rb', line 993

def has_alias?(name)
end

#has_column?(name) ⇒ Boolean

This method is used to determine whether a Row object contains a given column name.

Parameters

name

A String containing the column name to check for.

Returns:

  • (Boolean)


982
983
# File 'lib/src.rb', line 982

def has_column?(name)
end

#has_key?(name) ⇒ Boolean

This method is used to determine whether a Row object contains a given column alias.

Parameters

name

A String containing the column name to check for.

Returns:

  • (Boolean)


971
972
# File 'lib/src.rb', line 971

def has_key?(name)
end

#has_value?(value) ⇒ Boolean

This method is used to determine whether a Row object contains a given column value.

Parameters

value

A reference to an object value to be checked for.

Returns:

  • (Boolean)


1004
1005
# File 'lib/src.rb', line 1004

def has_value?(value)
end

#keysObject

This method retrieves an array of column aliases for a Row object.



1011
1012
# File 'lib/src.rb', line 1011

def keys
end

#namesObject

This method retrieves an array of column names for a Row object.



1018
1019
# File 'lib/src.rb', line 1018

def names
end

#numberObject

This is the accessor for the row number attribute. This will generally reflect the order the row was fetched from the result set in, with 1 being the first row retrieved.



876
877
# File 'lib/src.rb', line 876

def number
end

#select {|column, value| ... } ⇒ Object

This method returns an array of the Row elements for which the specified block returns true.

Yields:

  • (column, value)


1040
1041
1042
# File 'lib/src.rb', line 1040

def select
   yield column, value
end

#to_aObject

This method retrieves an Array containing the values from a Row object. Each value is represented as an Array containing a column name and the associated column value.



1050
1051
# File 'lib/src.rb', line 1050

def to_a
end

#to_hashObject

This method retrieves a Hash created from a Row objects values. The Row objects column names will be used as a key on to the column values.



1058
1059
# File 'lib/src.rb', line 1058

def to_hash
end

#valuesObject

This method retrieves an array of column values for a Row object.



1032
1033
# File 'lib/src.rb', line 1032

def values
end

#values_at(*names) ⇒ Object

This method returns an array of column values based on a list of column aliases.

Parameters

names

One or more Strings containing the names of the columns to retrieve values for.



1070
1071
# File 'lib/src.rb', line 1070

def values_at(*names)
end