# 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 PickleStepArgument message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
    ##
    #
    # An optional argument
    ##
    class PickleStepArgument < Message
      attr_reader :doc_string

      attr_reader :data_table

      def initialize(
        doc_string: nil,
        data_table: nil
      )
        @doc_string = doc_string
        @data_table = data_table
        super()
      end

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

        new(
          doc_string: PickleDocString.from_h(hash[:docString]),
          data_table: PickleTable.from_h(hash[:dataTable])
        )
      end
    end
  end
end
