Class: Nexmo::OAS::Renderer::Presenters::ApiSpecification
- Inherits:
-
Object
- Object
- Nexmo::OAS::Renderer::Presenters::ApiSpecification
- Defined in:
- lib/nexmo/oas/renderer/presenters/api_specification.rb
Instance Method Summary collapse
- #content ⇒ Object
- #document ⇒ Object
- #document_path ⇒ Object
- #document_title ⇒ Object
- #frontmatter ⇒ Object
-
#initialize(document_name:, code_language: nil) ⇒ ApiSpecification
constructor
A new instance of ApiSpecification.
- #side_navigation ⇒ Object
- #side_navigation_title ⇒ Object
Constructor Details
#initialize(document_name:, code_language: nil) ⇒ ApiSpecification
Returns a new instance of ApiSpecification.
8 9 10 11 |
# 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 |
Instance Method Details
#content ⇒ Object
45 46 47 48 49 |
# File 'lib/nexmo/oas/renderer/presenters/api_specification.rb', line 45 def content = {} .merge(code_language: @code_language) if @code_language @content ||= Nexmo::Markdown::Renderer.new().call(document) end |
#document ⇒ Object
29 30 31 |
# File 'lib/nexmo/oas/renderer/presenters/api_specification.rb', line 29 def document @document ||= File.read(document_path) end |
#document_path ⇒ Object
21 22 23 24 25 26 27 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/nexmo/oas/renderer/presenters/api_specification.rb', line 41 def document_title @document_title ||= "#{} > #{frontmatter.fetch('title')}" end |
#frontmatter ⇒ Object
33 34 35 |
# File 'lib/nexmo/oas/renderer/presenters/api_specification.rb', line 33 def frontmatter @frontmatter ||= YAML.safe_load(document) end |
#side_navigation ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/nexmo/oas/renderer/presenters/api_specification.rb', line 13 def if defined?(NexmoDeveloper::Application) "#{Rails.configuration.docs_base_path}/api/#{@document_name}" else "api/#{@document_name}" end end |
#side_navigation_title ⇒ Object
37 38 39 |
# File 'lib/nexmo/oas/renderer/presenters/api_specification.rb', line 37 def @side_navigation_title ||= frontmatter.fetch('api') end |