Class: CukeModeler::Table

Inherits:
Model
  • Object
show all
Includes:
Parsed, Parsing, Sourceable
Defined in:
lib/cuke_modeler/models/table.rb

Overview

A class modeling a step’s table.

Instance Attribute Summary collapse

Attributes included from Sourceable

#source_line

Attributes included from Parsed

#parsing_data

Attributes included from Nested

#parent_model

Instance Method Summary collapse

Methods included from Parsing

dialects, parse_text

Methods included from Containing

#each_descendant, #each_model

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source_text = nil) ⇒ Table

Creates a new Table object and, if source_text is provided, populates the object.



18
19
20
21
22
23
24
25
26
27
# File 'lib/cuke_modeler/models/table.rb', line 18

def initialize(source_text = nil)
  @rows = []

  super(source_text)

  if source_text
    parsed_table_data = parse_source(source_text)
    populate_table(self, parsed_table_data)
  end
end

Instance Attribute Details

#rowsObject

The row models that make up the table



13
14
15
# File 'lib/cuke_modeler/models/table.rb', line 13

def rows
  @rows
end

Instance Method Details

#childrenObject

Returns the model objects that belong to this model.



30
31
32
# File 'lib/cuke_modeler/models/table.rb', line 30

def children
  rows
end

#to_sObject

Returns a string representation of this model. For a table model, this will be Gherkin text that is equivalent to the table being modeled.



36
37
38
# File 'lib/cuke_modeler/models/table.rb', line 36

def to_s
  rows.empty? ? '' : rows.collect { |row| row_output_string(row) }.join("\n")
end