Class: CucumberJunitToJson::Models::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_junit_to_json/models/table.rb

Overview

Abstract representation of a cucumber step table attribute

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTable

Returns a new instance of Table.



10
11
12
13
# File 'lib/cucumber_junit_to_json/models/table.rb', line 10

def initialize
  @headings = []
  @rows = []
end

Instance Attribute Details

#headingsObject

Returns the value of attribute headings.



9
10
11
# File 'lib/cucumber_junit_to_json/models/table.rb', line 9

def headings
  @headings
end

#rowsObject

Returns the value of attribute rows.



9
10
11
# File 'lib/cucumber_junit_to_json/models/table.rb', line 9

def rows
  @rows
end

Class Method Details

.parse(data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/cucumber_junit_to_json/models/table.rb', line 15

def self.parse(data)
  table = Table.new
  table.headings = data.first.split('|').compact.collect(&:strip).reject(&:empty?)
  rows = []
  data.drop(1).each do |row|
    rows.push(row.split('|').compact.collect(&:strip).reject(&:empty?))
  end
  table.rows = rows
  table
end