Method: Marktable::Row#to_h
- Defined in:
- lib/marktable/row.rb
#to_h ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/marktable/row.rb', line 57 def to_h return @data if @data.is_a?(Hash) return {} if @data.empty? || @headers.nil? || @headers.empty? @headers.each_with_index.each_with_object({}) do |(header, i), hash| hash[header] = i < @data.length ? @data[i] : '' end end |