Sha256: 967201d17ace8156716864752b9c12426a5116fe4a1d78e1a9f2eafd32bce91b

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module Nexmo
  module OAS
    module Renderer
      module Presenters
        class ApiSpecification

          def initialize(document_name:, code_language: nil)
            @document_name = document_name
            @code_language = code_language
          end

          def side_navigation
            "api/#{@document_name}"
          end

          def document_path
            "_api/#{@document_name}.md"
          end

          def document
            @document ||= File.read(document_path)
          end

          def frontmatter
            @frontmatter ||= YAML.safe_load(document)
          end

          def side_navigation_title
            @side_navigation_title ||= frontmatter.fetch('api')
          end

          def document_title
            @document_title ||= "#{side_navigation_title} > #{frontmatter.fetch('title')}"
          end

          def content
            options = {}
            options.merge(code_language: @code_language) if @code_language
            @content ||= Nexmo::Markdown::Renderer.new(options).call(document)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nexmo-oas-renderer-0.11.3 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.11.2 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.11.1 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.11.0 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.10.0 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.9.0 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.8.0 lib/nexmo/oas/renderer/presenters/api_specification.rb