Class: DB2Query::Result::Record
- Inherits:
-
Object
- Object
- DB2Query::Result::Record
- Defined in:
- lib/db2_query/result.rb
Instance Attribute Summary collapse
-
#formatters ⇒ Object
readonly
Returns the value of attribute formatters.
Instance Method Summary collapse
-
#initialize(row, columns, formatters) ⇒ Record
constructor
A new instance of Record.
- #inspect ⇒ Object
Constructor Details
#initialize(row, columns, formatters) ⇒ Record
Returns a new instance of Record.
29 30 31 32 33 34 35 36 |
# File 'lib/db2_query/result.rb', line 29 def initialize(row, columns, formatters) @formatters = formatters columns.zip(row) do |col, val| column, value = format(col, val) singleton_class.class_eval { attr_accessor "#{column}" } send("#{column}=", value) end end |
Instance Attribute Details
#formatters ⇒ Object (readonly)
Returns the value of attribute formatters.
27 28 29 |
# File 'lib/db2_query/result.rb', line 27 def formatters @formatters end |
Instance Method Details
#inspect ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/db2_query/result.rb', line 38 def inspect inspection = if defined?(instance_variables) && instance_variables instance_variables.reject { |var| var == :@formatters }.map do |attr| value = instance_variable_get(attr) "#{attr[1..-1]}: #{(value.kind_of? String) ? %Q{"#{value}"} : value}" end.compact.join(", ") else "not initialized" end "#<Record #{inspection}>" end |