Class: DSP::DSPBase

Inherits:
Object
  • Object
show all
Defined in:
lib/dsp/dsp_base.rb

Direct Known Subclasses

AttachRequest, AttachRequestArguments, AttachResponse, Breakpoint, BreakpointEvent, BreakpointLocation, BreakpointLocationsArguments, BreakpointLocationsRequest, BreakpointLocationsResponse, CancelArguments, CancelRequest, CancelResponse, Capabilities, CapabilitiesEvent, Checksum, ColumnDescriptor, CompletionItem, CompletionsArguments, CompletionsRequest, CompletionsResponse, ConfigurationDoneArguments, ConfigurationDoneRequest, ConfigurationDoneResponse, ContinueArguments, ContinueRequest, ContinueResponse, ContinuedEvent, DataBreakpoint, DataBreakpointInfoArguments, DataBreakpointInfoRequest, DataBreakpointInfoResponse, DisassembleArguments, DisassembleRequest, DisassembleResponse, DisassembledInstruction, DisconnectArguments, DisconnectRequest, DisconnectResponse, ErrorResponse, EvaluateArguments, EvaluateRequest, EvaluateResponse, Event, ExceptionBreakpointsFilter, ExceptionDetails, ExceptionInfoArguments, ExceptionInfoRequest, ExceptionInfoResponse, ExceptionOptions, ExceptionPathSegment, ExitedEvent, FunctionBreakpoint, GotoArguments, GotoRequest, GotoResponse, GotoTarget, GotoTargetsArguments, GotoTargetsRequest, GotoTargetsResponse, InitializeRequest, InitializeRequestArguments, InitializeResponse, InitializedEvent, LaunchRequest, LaunchRequestArguments, LaunchResponse, LoadedSourceEvent, LoadedSourcesArguments, LoadedSourcesRequest, LoadedSourcesResponse, Message, Module, ModuleEvent, ModulesArguments, ModulesRequest, ModulesResponse, ModulesViewDescriptor, NextArguments, NextRequest, NextResponse, OutputEvent, PauseArguments, PauseRequest, PauseResponse, ProcessEvent, ProgressEndEvent, ProgressStartEvent, ProgressUpdateEvent, ProtocolMessage, ReadMemoryArguments, ReadMemoryRequest, ReadMemoryResponse, Request, Response, RestartArguments, RestartFrameArguments, RestartFrameRequest, RestartFrameResponse, RestartRequest, RestartResponse, ReverseContinueArguments, ReverseContinueRequest, ReverseContinueResponse, RunInTerminalRequest, RunInTerminalRequestArguments, RunInTerminalResponse, Scope, ScopesArguments, ScopesRequest, ScopesResponse, SetBreakpointsArguments, SetBreakpointsRequest, SetBreakpointsResponse, SetDataBreakpointsArguments, SetDataBreakpointsRequest, SetDataBreakpointsResponse, SetExceptionBreakpointsArguments, SetExceptionBreakpointsRequest, SetExceptionBreakpointsResponse, SetExpressionArguments, SetExpressionRequest, SetExpressionResponse, SetFunctionBreakpointsArguments, SetFunctionBreakpointsRequest, SetFunctionBreakpointsResponse, SetVariableArguments, SetVariableRequest, SetVariableResponse, Source, SourceArguments, SourceBreakpoint, SourceRequest, SourceResponse, StackFrame, StackFrameFormat, StackTraceArguments, StackTraceRequest, StackTraceResponse, StepBackArguments, StepBackRequest, StepBackResponse, StepInArguments, StepInRequest, StepInResponse, StepInTarget, StepInTargetsArguments, StepInTargetsRequest, StepInTargetsResponse, StepOutArguments, StepOutRequest, StepOutResponse, StoppedEvent, TerminateArguments, TerminateRequest, TerminateResponse, TerminateThreadsArguments, TerminateThreadsRequest, TerminateThreadsResponse, TerminatedEvent, Thread, ThreadEvent, ThreadsRequest, ThreadsResponse, ValueFormat, Variable, VariablePresentationHint, VariablesArguments, VariablesRequest, VariablesResponse

Instance Method Summary collapse

Constructor Details

#initialize(initial_hash = nil) ⇒ DSPBase

Returns a new instance of DSPBase.



7
8
9
# File 'lib/dsp/dsp_base.rb', line 7

def initialize(initial_hash = nil)
  from_h!(initial_hash) unless initial_hash.nil?
end

Instance Method Details

#from_h!(value) ⇒ Object



29
# File 'lib/dsp/dsp_base.rb', line 29

def from_h!(value); end

#to_hObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dsp/dsp_base.rb', line 11

def to_h
  value = {}
  optional_names = @optional_method_names.nil? ? [] : @optional_method_names

  instance_method_names.each do |name|
    item_value = send(name)
    if item_value.is_a?(Array)
      # Convert the items in the array .to_h
      item_value = item_value.map { |item| item.to_h }
    elsif !item_value.nil? && item_value.respond_to?(:to_h)
      item_value = item_value.to_h
    end
    value[name.to_s] = item_value unless optional_names.include?(name) && item_value.nil?
  end

  value
end

#to_json(*options) ⇒ Object



31
32
33
# File 'lib/dsp/dsp_base.rb', line 31

def to_json(*options)
  to_h.to_json(options)
end