Class: DAP::ProtocolMessage

Inherits:
Base
  • Object
show all
Defined in:
lib/dap/protocol_message.rb

Overview

Base class of requests, responses, and events.

Direct Known Subclasses

Event, Request, Response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], build, empty, many, one_of, properties, property, property_names, #to_wire, transform, #validate!

Constructor Details

#initialize(values) ⇒ ProtocolMessage

Create a new instance of the receiver.

Parameters:

  • values (Hash)

    the object’s attributes



33
34
35
36
37
# File 'lib/dap/protocol_message.rb', line 33

def initialize(values)
  super(values)
  @seq = values[:seq] || DAP::ProtocolMessage.seq
  @type = self.class.type
end

Class Method Details

.from(values) ⇒ Object

Create a protocol message from attribute values.

Parameters:

  • values (Hash)

    the attribute values



15
16
17
18
19
20
21
22
23
# File 'lib/dap/protocol_message.rb', line 15

def self.from(values)
  build(values) do |v|
    key = v[:type]&.to_sym
    raise "#{name}.type missing" if key.nil?
    raise "Unknown #{name}.type #{key}" unless types.key?(key)

    types[key]
  end
end

.typesHash<Symbol,Class>

Valid protocol message types.

Returns:

  • (Hash<Symbol,Class>)


5
6
7
8
9
10
11
# File 'lib/dap/protocol_message.rb', line 5

def self.types
  @types ||= {
    request: DAP::Request,
    event: DAP::Event,
    response: DAP::Response,
  }
end