Class: Gapic::Presenters::SnippetPresenter::SimpleResponseHandlingPresenter

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

Overview

Presentation information about simple response handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, _json, response_type:, phase1:) ⇒ SimpleResponseHandlingPresenter

Create a simple response handling presenter

Parameters:

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

    The protobuf representation

  • json (String)

    The JSON representation

  • response_type (String)

    The fully qualified response message class

  • phase1 (Boolean)

    True if this is a phase 1 snippet without config



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 50

def initialize proto, _json, response_type:, phase1:
  @response_name = compute_response_name proto, phase1
  @render_lines =
    if @response_name && phase1
      [
        "# The returned object is of type #{response_type}.",
        "p #{@response_name}"
      ]
    else
      []
    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)


74
75
76
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 74

def render
  @render
end

#render_linesArray<String> (readonly)

The lines of rendered code

Returns:

  • (Array<String>)


68
69
70
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 68

def render_lines
  @render_lines
end

#response_nameString? (readonly)

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

Returns:

  • (String, nil)


80
81
82
# File 'lib/gapic/presenters/snippet/response_handling_presenters.rb', line 80

def response_name
  @response_name
end