lib/cucumber/messages/pickle_tag.rb



# frozen_string_literal: true

# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
module Cucumber
  module Messages
    ##
    # Represents the PickleTag message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
    ##
    #
    # *
    #  A tag
    ##
    class PickleTag < Message
      attr_reader :name

      ##
      # Points to the AST node this was created from
      ##
      attr_reader :ast_node_id

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

      ##
      # Returns a new PickleTag from the given hash.
      # If the hash keys are camelCased, they are properly assigned to the
      # corresponding snake_cased attributes.
      #
      #   Cucumber::Messages::PickleTag.from_h(some_hash) # => #<Cucumber::Messages::PickleTag:0x... ...>
      ##
      def self.from_h(hash)
        return nil if hash.nil?

        new(
          name: hash[:name],
          ast_node_id: hash[:astNodeId]
        )
      end
    end
  end
end