class CukeModeler::Cell

A class modeling a single cell of a row.

Attributes

value[RW]

The value of the cell

Public Class Methods

new(source_text = nil) click to toggle source

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

@example

Cell.new
Cell.new('some value')

@param source_text [String] The Gherkin text that will be used to populate the model @raise [ArgumentError] If source_text is not a String @return [Cell] A new Cell instance

Calls superclass method
# File lib/cuke_modeler/models/cell.rb, line 25
def initialize(source_text = nil)
  super
end

Public Instance Methods

inspect(verbose: false) click to toggle source

See ‘Object#inspect`. Returns some basic information about the object, including its class, object ID, and its most meaningful attribute. For a Cell model, this will be the value of the cell. If verbose is true, provides default Ruby inspection behavior instead.

@example

cell.inspect
cell.inspect(verbose: true)

@param verbose [Boolean] Whether or not to return the full details of

the object. Defaults to false.

@return [String] A string representation of this model

Calls superclass method
# File lib/cuke_modeler/models/cell.rb, line 54
def inspect(verbose: false)
  return super if verbose

  "#{super.chop} @value: #{value.inspect}>"
end
to_s() click to toggle source

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

@example

cell.to_s

@return [String] A string representation of this model

# File lib/cuke_modeler/models/cell.rb, line 36
def to_s
  # Vertical bars and backslashes are special characters that need to be escaped
  @value ? @value.gsub('\\', '\\\\\\').gsub('|', '\|') : ''
end

Private Instance Methods

populate_cell_value(parsed_cell_data) click to toggle source
# File lib/cuke_modeler/models/cell.rb, line 82
def populate_cell_value(parsed_cell_data)
  @value = parsed_cell_data['value']
end
populate_model(parsed_cell_data) click to toggle source
# File lib/cuke_modeler/models/cell.rb, line 76
def populate_model(parsed_cell_data)
  populate_cell_value(parsed_cell_data)
  populate_source_location(parsed_cell_data)
  populate_parsing_data(parsed_cell_data)
end
process_source(source_text) click to toggle source
# File lib/cuke_modeler/models/cell.rb, line 64
def process_source(source_text)
  base_file_string = "# language: #{Parsing.dialect}
  #{dialect_feature_keyword}: Fake feature to parse
                        #{dialect_scenario_keyword}:
                          #{dialect_step_keyword} fake step\n"
  source_text = "#{base_file_string}|#{source_text}|"

  parsed_file = Parsing.parse_text(source_text, 'cuke_modeler_stand_alone_cell.feature')

  parsed_file['feature']['elements'].first['steps'].first['table']['rows'].first['cells'].first
end