Class: Cucumber::Messages::Product

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

Overview

Represents the Product message in Cucumber’s message protocol.

Used to describe various properties of Meta

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(name: '', version: nil) ⇒ Product

Returns a new instance of Product.



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

def initialize(
  name: '',
  version: nil
)
  @name = name
  @version = version
  super()
end

Instance Attribute Details

#nameObject (readonly)

The product name



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

def name
  @name
end

#versionObject (readonly)

The product version



21
22
23
# File 'lib/cucumber/messages/product.rb', line 21

def version
  @version
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


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

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

  new(
    name: hash[:name],
    version: hash[:version]
  )
end