class Cucumber::Messages::Snippet
Represents the Snippet message in Cucumber’s message protocol.
Attributes
A snippet of code
The programming language of the code.
This must be formatted as an all lowercase identifier such that syntax highlighters like [Prism](prismjs.com/#supported-languages) or [Highlight.js](github.com/highlightjs/highlight.js/blob/main/SUPPORTED_LANGUAGES.md) can recognize it. For example: ‘cpp`, `cs`, `go`, `java`, `javascript`, `php`, `python`, `ruby`, `scala`.
Public Class Methods
Source
# File lib/cucumber/messages/snippet.rb, line 40 def self.from_h(hash) return nil if hash.nil? new( language: hash[:language], code: hash[:code] ) end
Returns a new Snippet from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.
Cucumber::Messages::Snippet.from_h(some_hash) # => #<Cucumber::Messages::Snippet:0x... ...>
Source
# File lib/cucumber/messages/snippet.rb, line 24 def initialize( language: '', code: '' ) @language = language @code = code super() end
Calls superclass method