Class: Trane::Docs::HtmlRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/trane/docs/html_renderer.rb

Constant Summary collapse

METHOD_COLORS =
{
  "GET" => "#61affe",
  "POST" => "#49cc90",
  "PUT" => "#fca130",
  "PATCH" => "#fca130",
  "DELETE" => "#f93e3e"
}.freeze
TEMPLATE_PATH =
File.expand_path("templates/index.html.erb", __dir__)
TEMPLATE =
ERB.new(File.read(TEMPLATE_PATH), trim_mode: "-").freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ HtmlRenderer

Returns a new instance of HtmlRenderer.



23
24
25
# File 'lib/trane/docs/html_renderer.rb', line 23

def initialize(definition)
  @definition = definition
end

Class Method Details

.render(definition) ⇒ Object



19
20
21
# File 'lib/trane/docs/html_renderer.rb', line 19

def self.render(definition)
  new(definition).to_html
end

Instance Method Details

#to_htmlObject



27
28
29
# File 'lib/trane/docs/html_renderer.rb', line 27

def to_html
  TEMPLATE.result(binding)
end