Class: DatabaseHelper::SQLQueryResult
- Inherits:
-
Object
- Object
- DatabaseHelper::SQLQueryResult
- Defined in:
- lib/inspec/utils/database_helpers.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #column(column) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(cmd, results) ⇒ SQLQueryResult
constructor
A new instance of SQLQueryResult.
- #inspect ⇒ Object
- #row(id) ⇒ Object
- #rows ⇒ Object
- #size ⇒ Object
- #successful? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(cmd, results) ⇒ SQLQueryResult
Returns a new instance of SQLQueryResult.
34 35 36 37 |
# File 'lib/inspec/utils/database_helpers.rb', line 34 def initialize(cmd, results) @cmd = cmd @results = results end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
33 34 35 |
# File 'lib/inspec/utils/database_helpers.rb', line 33 def error @error end |
Instance Method Details
#column(column) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/inspec/utils/database_helpers.rb', line 55 def column(column) result = [] @results.each do |row| result << row[column] end result end |
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/inspec/utils/database_helpers.rb', line 39 def empty? @results.empty? end |
#inspect ⇒ Object
67 68 69 |
# File 'lib/inspec/utils/database_helpers.rb', line 67 def inspect to_s end |
#row(id) ⇒ Object
51 52 53 |
# File 'lib/inspec/utils/database_helpers.rb', line 51 def row(id) SQLRow.new(self, @results[id]) end |
#rows ⇒ Object
47 48 49 |
# File 'lib/inspec/utils/database_helpers.rb', line 47 def rows @results end |
#size ⇒ Object
63 64 65 |
# File 'lib/inspec/utils/database_helpers.rb', line 63 def size @results.size end |
#successful? ⇒ Boolean
43 44 45 |
# File 'lib/inspec/utils/database_helpers.rb', line 43 def successful? @cmd.exit_status == 0 && @error.nil? end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/inspec/utils/database_helpers.rb', line 71 def to_s "SQL ResultSet" end |