Class: Cucumber::Messages::StepDefinition
- Defined in:
- lib/cucumber/messages/step_definition.rb
Overview
Represents the StepDefinition message in Cucumber’s message protocol.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#source_reference ⇒ Object
readonly
Returns the value of attribute source_reference.
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
Returns a new StepDefinition from the given hash.
Instance Method Summary collapse
-
#initialize(id: '', pattern: StepDefinitionPattern.new, source_reference: SourceReference.new) ⇒ StepDefinition
constructor
A new instance of StepDefinition.
Methods inherited from Message
camelize, from_json, #to_h, #to_json
Constructor Details
#initialize(id: '', pattern: StepDefinitionPattern.new, source_reference: SourceReference.new) ⇒ StepDefinition
Returns a new instance of StepDefinition.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cucumber/messages/step_definition.rb', line 17 def initialize( id: '', pattern: StepDefinitionPattern.new, source_reference: SourceReference.new ) @id = id @pattern = pattern @source_reference = source_reference super() end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/cucumber/messages/step_definition.rb', line 11 def id @id end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
13 14 15 |
# File 'lib/cucumber/messages/step_definition.rb', line 13 def pattern @pattern end |
#source_reference ⇒ Object (readonly)
Returns the value of attribute source_reference.
15 16 17 |
# File 'lib/cucumber/messages/step_definition.rb', line 15 def source_reference @source_reference end |
Class Method Details
.from_h(hash) ⇒ Object
Returns a new StepDefinition from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.
Cucumber::Messages::StepDefinition.from_h(some_hash) # => #<Cucumber::Messages::StepDefinition:0x... ...>
35 36 37 38 39 40 41 42 43 |
# File 'lib/cucumber/messages/step_definition.rb', line 35 def self.from_h(hash) return nil if hash.nil? new( id: hash[:id], pattern: StepDefinitionPattern.from_h(hash[:pattern]), source_reference: SourceReference.from_h(hash[:sourceReference]) ) end |