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.



525
526
527
528
# File 'lib/cucumber/multiline_argument/data_table.rb', line 525

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

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



523
524
525
# File 'lib/cucumber/multiline_argument/data_table.rb', line 523

def exception
  @exception
end

Instance Method Details

#[](index) ⇒ Object



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

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

#accept(visitor) ⇒ Object



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

def accept(visitor)
  return if Cucumber.wants_to_quit

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

#dom_idObject



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

def dom_id
  "row_#{line}"
end

#each(&proc) ⇒ Object



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

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

#lineObject



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

def line
  @cells[0].line
end

#to_hashObject



543
544
545
# File 'lib/cucumber/multiline_argument/data_table.rb', line 543

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

#to_sexpObject



539
540
541
# File 'lib/cucumber/multiline_argument/data_table.rb', line 539

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

#value(index) ⇒ Object



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

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