Class: RamlDoc::View

Inherits:
Object
  • Object
show all
Includes:
RamlHelper
Defined in:
lib/raml_doc/view.rb

Instance Method Summary collapse

Methods included from RamlHelper

#max_parameter

Constructor Details

#initialize(raml) ⇒ View

Returns a new instance of View.



8
9
10
# File 'lib/raml_doc/view.rb', line 8

def initialize(raml)
  @raml = raml
end

Instance Method Details

#markdown(string) ⇒ Object



23
24
25
# File 'lib/raml_doc/view.rb', line 23

def markdown(string)
  Kramdown::Document.new(string).to_html
end

#method_element_id(method, *args) ⇒ Object



27
28
29
30
31
# File 'lib/raml_doc/view.rb', line 27

def method_element_id(method, *args)
  args << method.name
  args << method.parent.resource_path_name
  args.compact.join "-"
end

#present?(value) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/raml_doc/view.rb', line 18

def present?(value)
  return !value.empty? if value.respond_to?(:empty?)
  !!value
end

#render(template, format) ⇒ Object



12
13
14
15
16
# File 'lib/raml_doc/view.rb', line 12

def render(template, format)
  template_path = File.join(File.expand_path("../templates", __FILE__), format, template, "index.#{format}.erb")
  template = ERB.new(File.read(template_path))
  template.result binding
end