Class: CucumberJunitToJson::Models::Table
- Inherits:
-
Object
- Object
- CucumberJunitToJson::Models::Table
- Defined in:
- lib/cucumber_junit_to_json/models/table.rb
Overview
Abstract representation of a cucumber step table attribute
Instance Attribute Summary collapse
-
#headings ⇒ Object
Returns the value of attribute headings.
-
#rows ⇒ Object
Returns the value of attribute rows.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Table
constructor
A new instance of Table.
Constructor Details
#initialize ⇒ Table
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
#headings ⇒ Object
Returns the value of attribute headings.
9 10 11 |
# File 'lib/cucumber_junit_to_json/models/table.rb', line 9 def headings @headings end |
#rows ⇒ Object
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 |