Class: CukeModeler::Cell

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

Overview

A class modeling a single cell of a row.

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) ⇒ Cell

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



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

def initialize(source_text = nil)
  super(source_text)

  if source_text
    parsed_cell_data = parse_source(source_text)
    populate_cell(self, parsed_cell_data)
  end
end

Instance Attribute Details

#valueObject

The value of the cell



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

def value
  @value
end

Instance Method Details

#to_sObject

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



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

def to_s
  # Vertical bars and backslashes are special characters that need to be escaped
  @value ? @value.gsub('\\', '\\\\\\').gsub('|', '\|') : ''
end