Sha256: 7e23b17c346918921b86e0417e2bcd5bd09a29ef7d10f1a05405ce416c7d20ea

Contents?: true

Size: 652 Bytes

Versions: 26

Compression:

Stored size: 652 Bytes

Contents

module Cucumber
  module Model
    class Table
      attr_accessor :raw
      
      # Creates a new table. The +raw+ argument should be an array
      # of arrays
      def initialize(raw)
        @raw = raw
      end
      
      # Turn the table into an array of Hash where each Hash
      # has keys corresponding to the table header (first line)
      # and the values are the individual row cells.
      def hashes
        header = @raw[0]
        @raw[1..-1].map do |row|
          h = {}
          row.each_with_index do |v,n|
            key = header[n]
            h[key] = v
          end
          h
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 6 rubygems

Version Path
aslakhellesoy-cucumber-0.1.10 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.11 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.12 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.13.2 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.13.3 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.13 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.14.1 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.14.2 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.15 lib/cucumber/model/table.rb
aslakhellesoy-cucumber-0.1.9 lib/cucumber/model/table.rb
bts-cucumber-0.1.13.1 lib/cucumber/model/table.rb
bts-cucumber-0.1.13.2 lib/cucumber/model/table.rb
bts-cucumber-0.1.13.3 lib/cucumber/model/table.rb
elight-cucumber-0.1.9 lib/cucumber/model/table.rb
jeffrafter-cucumber-0.1.10 lib/cucumber/model/table.rb
jeffrafter-cucumber-0.1.12 lib/cucumber/model/table.rb
cucumber-0.1.10 lib/cucumber/model/table.rb
cucumber-0.1.11 lib/cucumber/model/table.rb
cucumber-0.1.14 lib/cucumber/model/table.rb
cucumber-0.1.12 lib/cucumber/model/table.rb