Class: Nexmo::OAS::Renderer::Presenters::ResponseTab::Panel

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo/oas/renderer/presenters/response_tab/panel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema:, index:, format:, content:, endpoint:, theme_light: nil) ⇒ Panel

rubocop:disable Metrics/ParameterLists



11
12
13
14
15
16
17
18
# File 'lib/nexmo/oas/renderer/presenters/response_tab/panel.rb', line 11

def initialize(schema:, index:, format:, content:, endpoint:, theme_light: nil) # rubocop:disable Metrics/ParameterLists
  @schema  = schema
  @index   = index
  @format  = format
  @content = content
  @endpoint = endpoint
  @theme_light = theme_light
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



9
10
11
# File 'lib/nexmo/oas/renderer/presenters/response_tab/panel.rb', line 9

def index
  @index
end

Instance Method Details

#contentObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nexmo/oas/renderer/presenters/response_tab/panel.rb', line 26

def content
  if @content.is_a?(Nexmo::OAS::Renderer::Presenters::ContentSwitcher)
    return @content.render
  end

  if @content == :responses
    Nexmo::OAS::Renderer::ResponseParserDecorator
      .new(@schema)
      .html(@format, xml_options: @schema['xml'], theme_light: @theme_light)
  else
    [:'open_api/_response_fields', locals: {
      schema: @schema,
      index: @index,
      format: @format,
      endpoint: @endpoint,
    }]
  end
end

#css_classesObject



20
21
22
23
24
# File 'lib/nexmo/oas/renderer/presenters/response_tab/panel.rb', line 20

def css_classes
  classes = ['Vlt-tabs__panel']
  classes << 'Vlt-tabs__panel_active' if @index.zero?
  classes.join(' ')
end