Class: Rubyfb::Row
Overview
This class models a row of data fetched as part of a SQL query.
Instance Method Summary collapse
-
#[](index) ⇒ Object
This method fetches the value associated with a column within a Row object.
-
#aliases ⇒ Object
This method retrieves an array of column aliases for a Row object.
-
#column_alias(index) ⇒ Object
This method fetches the alias of a column within a row of data.
-
#column_count ⇒ Object
This method fetches a count of the number of columns of data that are available from a row.
-
#column_name(index) ⇒ Object
This method fetches the name of a column within a row of data.
-
#column_scale(column) ⇒ Object
This method fetches the scale associated with a specified column within a row of data.
-
#each {|column, vlaue| ... } ⇒ Object
This method iterates over the contents of a Row object.
-
#each_key {|column| ... } ⇒ Object
This method iterates over the column names for a Row class.
-
#each_value {|value| ... } ⇒ Object
This method iterators over the column values for a Row class.
-
#fetch(key, alternative = nil) {|key| ... } ⇒ Object
An implementation of the Hash#fetch method for the Row class.
-
#get_base_type(index) ⇒ Object
This method retrieves the base SQL type for a column of data within a Row object.
-
#has_alias?(name) ⇒ Boolean
This method is used to determine whether a Row object contains a given column alias.
-
#has_column?(name) ⇒ Boolean
This method is used to determine whether a Row object contains a given column name.
-
#has_key?(name) ⇒ Boolean
This method is used to determine whether a Row object contains a given column alias.
-
#has_value?(value) ⇒ Boolean
This method is used to determine whether a Row object contains a given column value.
-
#initialize(results, data, number) ⇒ Row
constructor
This is the constructor for the Row class.
-
#keys ⇒ Object
This method retrieves an array of column aliases for a Row object.
-
#names ⇒ Object
This method retrieves an array of column names for a Row object.
-
#number ⇒ Object
This is the accessor for the row number attribute.
-
#select {|column, value| ... } ⇒ Object
This method returns an array of the Row elements for which the specified block returns true.
-
#to_a ⇒ Object
This method retrieves an Array containing the values from a Row object.
-
#to_hash ⇒ Object
This method retrieves a Hash created from a Row objects values.
-
#values ⇒ Object
This method retrieves an array of column values for a Row object.
-
#values_at(*names) ⇒ Object
This method returns an array of column values based on a list of column aliases.
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.
938 939 |
# File 'lib/src.rb', line 938 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).
1003 1004 |
# File 'lib/src.rb', line 1003 def [](index) end |
#aliases ⇒ Object
This method retrieves an array of column aliases for a Row object.
1109 1110 |
# File 'lib/src.rb', line 1109 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.
977 978 |
# File 'lib/src.rb', line 977 def column_alias(index) end |
#column_count ⇒ Object
This method fetches a count of the number of columns of data that are available from a row.
954 955 |
# File 'lib/src.rb', line 954 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.
966 967 |
# File 'lib/src.rb', line 966 def column_name(index) end |
#column_scale(column) ⇒ Object
This method fetches the scale associated with a specified column within a row of data. See the documentation of ResultSet#column_scale for details.
Parameters
- column
-
A reference to the column number to fetch the details for. Column numbers start at zero.
990 991 |
# File 'lib/src.rb', line 990 def column_scale(column) 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.
1012 1013 1014 |
# File 'lib/src.rb', line 1012 def each yield column, vlaue end |
#each_key {|column| ... } ⇒ Object
This method iterates over the column names for a Row class.
1020 1021 1022 |
# File 'lib/src.rb', line 1020 def each_key yield column end |
#each_value {|value| ... } ⇒ Object
This method iterators over the column values for a Row class.
1028 1029 1030 |
# File 'lib/src.rb', line 1028 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.
1043 1044 1045 |
# File 'lib/src.rb', line 1043 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.
1166 1167 |
# File 'lib/src.rb', line 1166 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.
1077 1078 |
# File 'lib/src.rb', line 1077 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.
1066 1067 |
# File 'lib/src.rb', line 1066 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.
1055 1056 |
# File 'lib/src.rb', line 1055 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.
1088 1089 |
# File 'lib/src.rb', line 1088 def has_value?(value) end |
#keys ⇒ Object
This method retrieves an array of column aliases for a Row object.
1095 1096 |
# File 'lib/src.rb', line 1095 def keys end |
#names ⇒ Object
This method retrieves an array of column names for a Row object.
1102 1103 |
# File 'lib/src.rb', line 1102 def names end |
#number ⇒ Object
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.
946 947 |
# File 'lib/src.rb', line 946 def number end |
#select {|column, value| ... } ⇒ Object
This method returns an array of the Row elements for which the specified block returns true.
1124 1125 1126 |
# File 'lib/src.rb', line 1124 def select yield column, value end |
#to_a ⇒ Object
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.
1134 1135 |
# File 'lib/src.rb', line 1134 def to_a end |
#to_hash ⇒ Object
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.
1142 1143 |
# File 'lib/src.rb', line 1142 def to_hash end |
#values ⇒ Object
This method retrieves an array of column values for a Row object.
1116 1117 |
# File 'lib/src.rb', line 1116 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.
1154 1155 |
# File 'lib/src.rb', line 1154 def values_at(*names) end |