Class: Cucumber::Messages::DocString

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

Overview

Represents the DocString 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(location: Location.new, media_type: nil, content: '', delimiter: '') ⇒ DocString

Returns a new instance of DocString.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cucumber/messages/doc_string.rb', line 19

def initialize(
  location: Location.new,
  media_type: nil,
  content: '',
  delimiter: ''
)
  @location = location
  @media_type = media_type
  @content = content
  @delimiter = delimiter
  super()
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



15
16
17
# File 'lib/cucumber/messages/doc_string.rb', line 15

def content
  @content
end

#delimiterObject (readonly)

Returns the value of attribute delimiter.



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

def delimiter
  @delimiter
end

#locationObject (readonly)

Returns the value of attribute location.



11
12
13
# File 'lib/cucumber/messages/doc_string.rb', line 11

def location
  @location
end

#media_typeObject (readonly)

Returns the value of attribute media_type.



13
14
15
# File 'lib/cucumber/messages/doc_string.rb', line 13

def media_type
  @media_type
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


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

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

  new(
    location: Location.from_h(hash[:location]),
    media_type: hash[:mediaType],
    content: hash[:content],
    delimiter: hash[:delimiter]
  )
end