Class: Cucumber::Messages::Examples

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

Overview

Represents the Examples 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, tags: [], keyword: '', name: '', description: '', table_header: nil, table_body: [], id: '') ⇒ Examples

Returns a new instance of Examples.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cucumber/messages/examples.rb', line 30

def initialize(
  location: Location.new,
  tags: [],
  keyword: '',
  name: '',
  description: '',
  table_header: nil,
  table_body: [],
  id: ''
)
  @location = location
  @tags = tags
  @keyword = keyword
  @name = name
  @description = description
  @table_header = table_header
  @table_body = table_body
  @id = id
  super()
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



22
23
24
# File 'lib/cucumber/messages/examples.rb', line 22

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



28
29
30
# File 'lib/cucumber/messages/examples.rb', line 28

def id
  @id
end

#keywordObject (readonly)

Returns the value of attribute keyword.



18
19
20
# File 'lib/cucumber/messages/examples.rb', line 18

def keyword
  @keyword
end

#locationObject (readonly)

The location of the ‘Examples` keyword



14
15
16
# File 'lib/cucumber/messages/examples.rb', line 14

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/cucumber/messages/examples.rb', line 20

def name
  @name
end

#table_bodyObject (readonly)

Returns the value of attribute table_body.



26
27
28
# File 'lib/cucumber/messages/examples.rb', line 26

def table_body
  @table_body
end

#table_headerObject (readonly)

Returns the value of attribute table_header.



24
25
26
# File 'lib/cucumber/messages/examples.rb', line 24

def table_header
  @table_header
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cucumber/messages/examples.rb', line 58

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

  new(
    location: Location.from_h(hash[:location]),
    tags: hash[:tags]&.map { |item| Tag.from_h(item) },
    keyword: hash[:keyword],
    name: hash[:name],
    description: hash[:description],
    table_header: TableRow.from_h(hash[:tableHeader]),
    table_body: hash[:tableBody]&.map { |item| TableRow.from_h(item) },
    id: hash[:id]
  )
end