Class: CukeModeler::Row

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

Overview

A class modeling a single row of a step table or example table.

Instance Attribute Summary collapse

Attributes included from Parsed

#parsing_data

Attributes included from Sourceable

#source_line

Attributes included from Nested

#parent_model

Instance Method Summary collapse

Methods included from Parsing

dialects, parse_text

Methods inherited from Model

#children

Methods included from Containing

#each_descendant, #each_model

Methods included from Nested

#get_ancestor

Constructor Details

#initialize(source_text = nil) ⇒ Row

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



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

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

  super(source_text)

  if source_text
    parsed_row_data = parse_source(source_text)
    populate_row(self, parsed_row_data)
  end
end

Instance Attribute Details

#cellsObject

The cell models that make up the row



12
13
14
# File 'lib/cuke_modeler/models/row.rb', line 12

def cells
  @cells
end

Instance Method Details

#to_sObject

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



30
31
32
33
34
# File 'lib/cuke_modeler/models/row.rb', line 30

def to_s
  text_cells = cells.collect { |cell| cell.to_s }

  "| #{text_cells.join(' | ')} |"
end