Class: Gapic::Presenters::SnippetPresenter::ClientCallPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/gapic/presenters/snippet/client_call_presenter.rb

Overview

Presentation information about client call invocation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, json, method_name:, request_name:, response_name:, client_streaming:, server_streaming:, phase1:) ⇒ ClientCallPresenter

Create a client call presenter

Parameters:

  • proto (Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1::Snippet::ClientCall)

    The protobuf representation

  • json (String)

    The JSON representation

  • method_name (String)

    The method name

  • request_name (String)

    The request variable name

  • response_name (String, nil)

    The response variable name, or nil for no response handling

  • client_streaming (Boolean)

    True if the call is client streaming

  • server_streaming (Boolean)

    True if the call is server streaming

  • phase1 (Boolean)

    True if this is a phase 1 snippet without config



39
40
41
42
43
44
45
46
# File 'lib/gapic/presenters/snippet/client_call_presenter.rb', line 39

def initialize proto, json,
               method_name:, request_name:, response_name:, client_streaming:, server_streaming:, phase1:
  @render_lines = pre_call_lines proto, json, method_name, client_streaming, server_streaming, phase1
  main_line = "client.#{method_name} #{request_name}"
  main_line = "#{response_name} = #{main_line}" if response_name
  @render_lines << main_line
  @render = @render_lines.join "\n"
end

Instance Attribute Details

#renderString (readonly)

The rendered code as a single string, possibly with line breaks

Returns:

  • (String)


58
59
60
# File 'lib/gapic/presenters/snippet/client_call_presenter.rb', line 58

def render
  @render
end

#render_linesArray<String> (readonly)

The lines of rendered code

Returns:

  • (Array<String>)


52
53
54
# File 'lib/gapic/presenters/snippet/client_call_presenter.rb', line 52

def render_lines
  @render_lines
end