Class: Cucumber::MultilineArgument::DataTable::Cells

Inherits:
Object
  • Object
show all
Includes:
Gherkin::Formatter::Escaping, Enumerable
Defined in:
lib/cucumber/multiline_argument/data_table.rb

Overview

Represents a row of cells or columns of cells

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gherkin::Formatter::Escaping

#escape_cell

Constructor Details

#initialize(table, cells) ⇒ Cells

Returns a new instance of Cells.



532
533
534
535
# File 'lib/cucumber/multiline_argument/data_table.rb', line 532

def initialize(table, cells)
  @table = table
  @cells = cells
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



530
531
532
# File 'lib/cucumber/multiline_argument/data_table.rb', line 530

def exception
  @exception
end

Instance Method Details

#[](index) ⇒ Object



558
559
560
# File 'lib/cucumber/multiline_argument/data_table.rb', line 558

def [](index)
  @cells[index]
end

#accept(visitor) ⇒ Object



537
538
539
540
541
542
543
544
# File 'lib/cucumber/multiline_argument/data_table.rb', line 537

def accept(visitor)
  return if Cucumber.wants_to_quit

  each do |cell|
    visitor.visit_table_cell(cell)
  end
  nil
end

#dom_idObject



566
567
568
# File 'lib/cucumber/multiline_argument/data_table.rb', line 566

def dom_id
  "row_#{line}"
end

#each(&proc) ⇒ Object



570
571
572
# File 'lib/cucumber/multiline_argument/data_table.rb', line 570

def each(&proc)
  @cells.each(&proc)
end

#lineObject



562
563
564
# File 'lib/cucumber/multiline_argument/data_table.rb', line 562

def line
  @cells[0].line
end

#to_hashObject



550
551
552
# File 'lib/cucumber/multiline_argument/data_table.rb', line 550

def to_hash
  @to_hash ||= @table.cells_to_hash(self)
end

#to_sexpObject



546
547
548
# File 'lib/cucumber/multiline_argument/data_table.rb', line 546

def to_sexp
  [:row, line, *@cells.map(&:to_sexp)]
end

#value(index) ⇒ Object



554
555
556
# File 'lib/cucumber/multiline_argument/data_table.rb', line 554

def value(index)
  self[index].value
end