Class: Gapic::Presenters::SnippetPresenter::ParameterPresenter

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

Overview

Presentation information about a snippet method parameter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, json) ⇒ ParameterPresenter

Create an expression presenter.

Parameters:

  • proto (Google::Cloud::Tools::SnippetGen::ConfigLanguage::V1::Statement::Declaration)

    The protobuf representation of the parameter

  • json (String)

    The JSON representation of the parameter



33
34
35
36
37
38
39
# File 'lib/gapic/presenters/snippet/parameter_presenter.rb', line 33

def initialize proto, json
  @name = proto.name
  @description = proto.description
  @description = nil if @description&.empty?
  @type = TypePresenter.new proto&.type, json&.fetch("type", nil)
  @example = ExpressionPresenter.new proto&.value, json&.fetch("value", nil)
end

Instance Attribute Details

#descriptionString? (readonly)

A description of this parameter, or nil if none.

Returns:

  • (String, nil)


51
52
53
# File 'lib/gapic/presenters/snippet/parameter_presenter.rb', line 51

def description
  @description
end

#exampleGapic::Presenters::SnippetPresenter::ExpressionPresenter (readonly)

The default/example value for this parameter, as a presenter.



63
64
65
# File 'lib/gapic/presenters/snippet/parameter_presenter.rb', line 63

def example
  @example
end

#nameString (readonly)

The name of this parameter

Returns:

  • (String)


45
46
47
# File 'lib/gapic/presenters/snippet/parameter_presenter.rb', line 45

def name
  @name
end

#typeGapic::Presenters::SnippetPresenter::TypePresenter (readonly)

The type of this parameter, as a presenter.



57
58
59
# File 'lib/gapic/presenters/snippet/parameter_presenter.rb', line 57

def type
  @type
end