Class: Cucumber::Messages::StepMatchArgument

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

Overview

Represents the StepMatchArgument message in Cucumber’s message protocol.

*

Represents a single argument extracted from a step match and passed to a step definition.
This is used for the following purposes:
- Construct an argument to pass to a step definition (possibly through a parameter type transform)
- Highlight the matched parameter in rich formatters such as the HTML formatter

This message closely matches the `Argument` class in the `cucumber-expressions` library.

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(group: Group.new, parameter_type_name: nil) ⇒ StepMatchArgument

Returns a new instance of StepMatchArgument.



28
29
30
31
32
33
34
35
# File 'lib/cucumber/messages/step_match_argument.rb', line 28

def initialize(
  group: Group.new,
  parameter_type_name: nil
)
  @group = group
  @parameter_type_name = parameter_type_name
  super()
end

Instance Attribute Details

#groupObject (readonly)

*

Represents the outermost capture group of an argument. This message closely matches the
`Group` class in the `cucumber-expressions` library.


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

def group
  @group
end

#parameter_type_nameObject (readonly)

Returns the value of attribute parameter_type_name.



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

def parameter_type_name
  @parameter_type_name
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


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

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

  new(
    group: Group.from_h(hash[:group]),
    parameter_type_name: hash[:parameterTypeName]
  )
end