Class: Cucumber::Messages::TableRow

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/table_row.rb

Overview

Represents the TableRow message in Cucumber’s message protocol.

A row in a table

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(location: Location.new, cells: [], id: '') ⇒ TableRow

Returns a new instance of TableRow.



25
26
27
28
29
30
31
32
33
34
# File 'lib/cucumber/messages/table_row.rb', line 25

def initialize(
  location: Location.new,
  cells: [],
  id: ''
)
  @location = location
  @cells = cells
  @id = id
  super()
end

Instance Attribute Details

#cellsObject (readonly)

Cells in the row



21
22
23
# File 'lib/cucumber/messages/table_row.rb', line 21

def cells
  @cells
end

#idObject (readonly)

Returns the value of attribute id.



23
24
25
# File 'lib/cucumber/messages/table_row.rb', line 23

def id
  @id
end

#locationObject (readonly)

The location of the first cell in the row



16
17
18
# File 'lib/cucumber/messages/table_row.rb', line 16

def location
  @location
end

Class Method Details

.from_h(hash) ⇒ Object

Returns a new TableRow from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::TableRow.from_h(some_hash) # => #<Cucumber::Messages::TableRow:0x... ...>


43
44
45
46
47
48
49
50
51
# File 'lib/cucumber/messages/table_row.rb', line 43

def self.from_h(hash)
  return nil if hash.nil?

  new(
    location: Location.from_h(hash[:location]),
    cells: hash[:cells]&.map { |item| TableCell.from_h(item) },
    id: hash[:id]
  )
end