Sha256: 3f11a519a99900aa072949010fb0ea9410ec5c6b972f53c4d276edc0edba31ed
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
class ExpectedResultSet attr_reader :rows, :columns def initialize(*names) @columns = names.map {|column| column.to_s} @rows = [] end def columns=(value) @columns = value.map {|entry| entry.to_s} end def row_hash(index) return to_hash( @rows[index] ) end def row_hashes return rows.collect { |row| to_hash(row) } end def add_fixture( *fixture_map ) row = [] @columns.each do |column| row << get_value_from_maps( column, fixture_map ) #(fixture_map[column.to_sym] or fixture_map[column.to_s]) end rows << row end def get_value_from_maps( key, fixture_maps) fixture_maps.each do |fixture_map| value = (fixture_map[key.to_sym] or fixture_map[key.to_s]) return value unless value.nil? end return nil end def with_row(row_hash) row = [] row_hash.each do |column, value| column = column.to_s if @columns.include? column row[@columns.index(column)] = value else @columns << column.to_s row << value end end @rows << row self end private def to_hash(row) result = {} columns.each_with_index { |column, i| result[column] = row[i] } return result end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
marjoree-0.0.9 | ./lib/expected_result_set.rb |