class Nexmo::OAS::Renderer::Presenters::ContentSwitcher

Attributes

panels[R]

Public Class Methods

new(format:, label: nil, theme_light:, force_type: nil) click to toggle source
# File lib/nexmo/oas/renderer/presenters/content_switcher.rb, line 10
def initialize(format:, label: nil, theme_light:, force_type: nil)
  @format = format
  @panels = []
  @label = label
  @force_type = force_type
  @theme_light = theme_light
end

Public Instance Methods

add_content(title:, content:, tab_id:, active:) click to toggle source
# File lib/nexmo/oas/renderer/presenters/content_switcher.rb, line 18
def add_content(title:, content:, tab_id:, active:)
  @panels.push({
                   'title' => title,
                   'content' => content,
                   'x-tab-id' => tab_id,
                   'active' => active,
               })
end
id() click to toggle source
# File lib/nexmo/oas/renderer/presenters/content_switcher.rb, line 42
def id
  @id ||= "s-#{SecureRandom.hex}"
end
render() click to toggle source
# File lib/nexmo/oas/renderer/presenters/content_switcher.rb, line 27
def render
  type = 'tabs'
  type = 'dropdown' if @panels.length >= 8

  type = @force_type if @force_type

  [:"open_api/content_switcher/_#{type}", locals: {
      panels: @panels,
      format: @format,
      label: @label,
      switcher: self,
      theme_light: @theme_light,
  }]
end