Class: Cucumber::Messages::DataTable

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

Overview

Represents the DataTable message in Cucumber’s message protocol.

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, rows: []) ⇒ DataTable

Returns a new instance of DataTable.



15
16
17
18
19
20
21
22
# File 'lib/cucumber/messages/data_table.rb', line 15

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



11
12
13
# File 'lib/cucumber/messages/data_table.rb', line 11

def location
  @location
end

#rowsObject (readonly)

Returns the value of attribute rows.



13
14
15
# File 'lib/cucumber/messages/data_table.rb', line 13

def rows
  @rows
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


31
32
33
34
35
36
37
38
# File 'lib/cucumber/messages/data_table.rb', line 31

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

  new(
    location: Location.from_h(hash[:location]),
    rows: hash[:rows]&.map { |item| TableRow.from_h(item) }
  )
end