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.



527
528
529
530
# File 'lib/cucumber/multiline_argument/data_table.rb', line 527

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

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



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

def exception
  @exception
end

Instance Method Details

#[](index) ⇒ Object



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

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

#accept(visitor) ⇒ Object



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

def accept(visitor)
  return if Cucumber.wants_to_quit

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

#dom_idObject



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

def dom_id
  "row_#{line}"
end

#each(&proc) ⇒ Object



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

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

#lineObject



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

def line
  @cells[0].line
end

#to_hashObject



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

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

#to_sexpObject



541
542
543
# File 'lib/cucumber/multiline_argument/data_table.rb', line 541

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

#value(index) ⇒ Object



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

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