Class: Cucumber::Messages::RuleChild

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

Overview

Represents the RuleChild message in Cucumber’s message protocol.

*

A child node of a `Rule` node

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(background: nil, scenario: nil) ⇒ RuleChild

Returns a new instance of RuleChild.



18
19
20
21
22
23
24
25
# File 'lib/cucumber/messages/rule_child.rb', line 18

def initialize(
  background: nil,
  scenario: nil
)
  @background = background
  @scenario = scenario
  super()
end

Instance Attribute Details

#backgroundObject (readonly)

Returns the value of attribute background.



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

def background
  @background
end

#scenarioObject (readonly)

Returns the value of attribute scenario.



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

def scenario
  @scenario
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


34
35
36
37
38
39
40
41
# File 'lib/cucumber/messages/rule_child.rb', line 34

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

  new(
    background: Background.from_h(hash[:background]),
    scenario: Scenario.from_h(hash[:scenario])
  )
end