Class: RSpec::Permutations::Parser::Table
- Inherits:
-
Object
- Object
- RSpec::Permutations::Parser::Table
- Defined in:
- lib/rspec/permutations/parser.rb
Class Method Summary collapse
Class Method Details
.parse(raw_table) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rspec/permutations/parser.rb', line 39 def parse(raw_table) headers, *rows = raw_table.strip.split("\n") headers = headers.strip.split("|").map(&:strip) headers = strip_start_and_end_blanks(headers) rows.map do |row| values = row.strip.split("|").compact.map(&:strip) values = strip_start_and_end_blanks(values) headers.each.with_object(Permutation.new(row)).with_index do |(header, hash), index| hash[header] = values[index] end end end |