Method: Marktable::Row#to_hash

Defined in:
lib/marktable/row.rb

#to_hashObject

Convert row data to a hash using headers as keys



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/marktable/row.rb', line 56

def to_hash
  return {} unless @headers

  result = {}
  @values.each_with_index do |value, i|
    # Only include values that have a corresponding header
    if i < @headers.size
      header = @headers[i]
      result[header] = value if header
    end
  end
  result
end