File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,17 @@ def save_csv(file_path, options = {})
214
214
@data . each { |rec | csv << rec }
215
215
end
216
216
end
217
+
218
+
219
+ # Convert the data in this source to Array<Hash> using the field names
220
+ # as keys for the Hash in each row.
221
+ def to_hash
222
+ @data . map do |row |
223
+ hsh = { }
224
+ @field_names . each_with_index . map { |fld , i | hsh [ fld ] = row [ i ] }
225
+ hsh
226
+ end
227
+ end
217
228
218
229
219
230
private
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ class XMLSource < Source
11
11
attr_accessor :context
12
12
13
13
# Create a new XMLSource, identified by +path+. Normally this is a path
14
- # to the XML document, but any value is fine, as it isreally just a label
15
- # to identify this data set.
14
+ # to the XML document, but any value is fine, as it is just a label to
15
+ # identify this data set.
16
16
#
17
17
# @param path [String] A label for this data set (often a path to the
18
18
# XML document used as the source).
You can’t perform that action at this time.
0 commit comments