Class: Cucumber::Messages::Tag

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

Overview

Represents the Tag message in Cucumber’s message protocol.

*

A tag

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, name: '', id: '') ⇒ Tag

Returns a new instance of Tag.



29
30
31
32
33
34
35
36
37
38
# File 'lib/cucumber/messages/tag.rb', line 29

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

Instance Attribute Details

#idObject (readonly)

Unique ID to be able to reference the Tag from PickleTag



27
28
29
# File 'lib/cucumber/messages/tag.rb', line 27

def id
  @id
end

#locationObject (readonly)

Location of the tag



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

def location
  @location
end

#nameObject (readonly)

The name of the tag (including the leading ‘@`)



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

def name
  @name
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


47
48
49
50
51
52
53
54
55
# File 'lib/cucumber/messages/tag.rb', line 47

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

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