Class: Cucumber::Messages::Comment

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

Overview

Represents the Comment message in Cucumber’s message protocol.

*

A comment in a Gherkin document

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, text: '') ⇒ Comment

Returns a new instance of Comment.



24
25
26
27
28
29
30
31
# File 'lib/cucumber/messages/comment.rb', line 24

def initialize(
  location: Location.new,
  text: ''
)
  @location = location
  @text = text
  super()
end

Instance Attribute Details

#locationObject (readonly)

The location of the comment



17
18
19
# File 'lib/cucumber/messages/comment.rb', line 17

def location
  @location
end

#textObject (readonly)

The text of the comment



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

def text
  @text
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


40
41
42
43
44
45
46
47
# File 'lib/cucumber/messages/comment.rb', line 40

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

  new(
    location: Location.from_h(hash[:location]),
    text: hash[:text]
  )
end