Class: Cucumber::Messages::ParameterType

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

Overview

Represents the ParameterType 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(name: '', regular_expressions: [], prefer_for_regular_expression_match: false, use_for_snippets: false, id: '', source_reference: nil) ⇒ ParameterType

Returns a new instance of ParameterType.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cucumber/messages/parameter_type.rb', line 26

def initialize(
  name: '',
  regular_expressions: [],
  prefer_for_regular_expression_match: false,
  use_for_snippets: false,
  id: '',
  source_reference: nil
)
  @name = name
  @regular_expressions = regular_expressions
  @prefer_for_regular_expression_match = prefer_for_regular_expression_match
  @use_for_snippets = use_for_snippets
  @id = id
  @source_reference = source_reference
  super()
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

The name is unique, so we don’t need an id.



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

def name
  @name
end

#prefer_for_regular_expression_matchObject (readonly)

Returns the value of attribute prefer_for_regular_expression_match.



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

def prefer_for_regular_expression_match
  @prefer_for_regular_expression_match
end

#regular_expressionsObject (readonly)

Returns the value of attribute regular_expressions.



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

def regular_expressions
  @regular_expressions
end

#source_referenceObject (readonly)

Returns the value of attribute source_reference.



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

def source_reference
  @source_reference
end

#use_for_snippetsObject (readonly)

Returns the value of attribute use_for_snippets.



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

def use_for_snippets
  @use_for_snippets
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cucumber/messages/parameter_type.rb', line 50

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

  new(
    name: hash[:name],
    regular_expressions: hash[:regularExpressions],
    prefer_for_regular_expression_match: hash[:preferForRegularExpressionMatch],
    use_for_snippets: hash[:useForSnippets],
    id: hash[:id],
    source_reference: SourceReference.from_h(hash[:sourceReference])
  )
end