Class: CukeModeler::Row
- 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
-
#cells ⇒ Object
The cell models that make up the row.
Attributes included from Parsed
Attributes included from Sourceable
Attributes included from Nested
Instance Method Summary collapse
-
#children ⇒ Array<Cell>
Returns the model objects that are children of this model.
-
#initialize(source_text = nil) ⇒ Row
constructor
Creates a new Row object and, if source_text is provided, populates the object.
-
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`.
-
#to_s ⇒ String
Returns a string representation of this model.
Methods included from Parsing
Methods included from Containing
#each, #each_descendant, #each_model
Methods included from Nested
Constructor Details
#initialize(source_text = nil) ⇒ Row
Creates a new Row object and, if source_text is provided, populates the object.
24 25 26 27 28 |
# File 'lib/cuke_modeler/models/row.rb', line 24 def initialize(source_text = nil) @cells = [] super end |
Instance Attribute Details
#cells ⇒ Object
The cell models that make up the row
11 12 13 |
# File 'lib/cuke_modeler/models/row.rb', line 11 def cells @cells end |
Instance Method Details
#children ⇒ Array<Cell>
Returns the model objects that are children of this model. For a Row model, these would be any associated Cell models.
37 38 39 |
# File 'lib/cuke_modeler/models/row.rb', line 37 def children @cells end |
#inspect(verbose: false) ⇒ String
See ‘Object#inspect`. Returns some basic information about the object, including its class, object ID, and its most meaningful attribute. For a Row model, this will be the cells of the row. If verbose is true, provides default Ruby inspection behavior instead.
67 68 69 70 71 72 73 |
# File 'lib/cuke_modeler/models/row.rb', line 67 def inspect(verbose: false) return super if verbose cell_output = @cells&.collect(&:value) "#{super.chop} @cells: #{cell_output.inspect}>" end |
#to_s ⇒ String
Returns a string representation of this model. For a Row model, this will be Gherkin text that is equivalent to the row being modeled.
48 49 50 51 52 |
# File 'lib/cuke_modeler/models/row.rb', line 48 def to_s text_cells = cells.map(&:to_s) "| #{text_cells.join(' | ')} |" end |