Class: Gapic::Presenters::SnippetPresenter::StreamingResponseHandlingPresenter

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

Overview

Presentation information about server-streaming response handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, json, response_name:, base_response_type:, phase1:) ⇒ StreamingResponseHandlingPresenter

Create a server-streaming response handling presenter

Parameters:

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

    The protobuf representation

  • json (String)

    The JSON representation

  • response_name (String)

    The name of the stream variable

  • base_response_type (String)

    The fully qualified message class for individual responses

  • phase1 (Boolean)

    True if this is a phase 1 snippet without config



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 180

def initialize proto, json, response_name:, base_response_type:, phase1:
  @response_name = response_name
  @render_lines = []
  if response_name
    if phase1 && base_response_type
      @render_lines << "# The returned object is a streamed enumerable yielding elements of type"
      @render_lines << "# #{base_response_type}"
    end
    @render_lines += per_stream_response_lines proto, json, response_name, phase1
  end
  @render = @render_lines.join "\n"
end

Instance Attribute Details

#renderString (readonly)

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

Returns:

  • (String)


203
204
205
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 203

def render
  @render
end

#render_linesArray<String> (readonly)

The lines of rendered code

Returns:

  • (Array<String>)


197
198
199
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 197

def render_lines
  @render_lines
end

#response_nameString? (readonly)

The name of the response variable, or nil for no response handling

Returns:

  • (String, nil)


209
210
211
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 209

def response_name
  @response_name
end