Class: Gapic::Presenters::SnippetPresenter::TypePresenter

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

Overview

Presentation information about a type

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, json) ⇒ TypePresenter

Create a type presenter.

Parameters:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/gapic/presenters/snippet/type_presenter.rb', line 34

def initialize proto, json
  @render =
    if json&.key? "scalarType"
      SCALAR_TYPE_MAPPING[proto.scalar_type] || "Object"
    elsif json&.key? "bytesType"
      "String"
    elsif json&.key? "messageType"
      proto_to_ruby proto.message_type.message_full_name
    elsif json&.key? "enumType"
      proto_to_ruby proto.enum_type.enum_full_name
    elsif json&.key? "repeatedType"
      repeated_render proto, json
    elsif json&.key? "mapType"
      map_render proto, json
    else
      "Object"
    end
end

Instance Attribute Details

#renderString (readonly)

The rendered type string.

Returns:

  • (String)


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

def render
  @render
end