class Nexmo::OAS::Renderer::Presenters::ApiSpecification

Public Class Methods

new(document_name:, code_language: nil) click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 8
def initialize(document_name:, code_language: nil)
  @document_name = document_name
  @code_language = code_language
end

Public Instance Methods

content() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 45
def content
  options = {}
  options.merge(code_language: @code_language) if @code_language
  @content ||= Nexmo::Markdown::Renderer.new(options).call(document)
end
document() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 29
def document
  @document ||= File.read(document_path)
end
document_path() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 21
def document_path
  if defined?(NexmoDeveloper::Application)
    "#{Rails.configuration.docs_base_path}/_api/#{@document_name}.md"
  else
    "_api/#{@document_name}.md"
  end
end
document_title() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 41
def document_title
  @document_title ||= "#{side_navigation_title} > #{frontmatter.fetch('title')}"
end
frontmatter() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 33
def frontmatter
  @frontmatter ||= YAML.safe_load(document)
end
side_navigation() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 13
def side_navigation
  if defined?(NexmoDeveloper::Application)
    "#{Rails.configuration.docs_base_path}/api/#{@document_name}"
  else
    "api/#{@document_name}"
  end
end
side_navigation_title() click to toggle source
# File lib/nexmo/oas/renderer/presenters/api_specification.rb, line 37
def side_navigation_title
  @side_navigation_title ||= frontmatter.fetch('api')
end