Class: RamlDoc::View
- Inherits:
-
Object
- Object
- RamlDoc::View
- Includes:
- RamlHelper
- Defined in:
- lib/raml_doc/view.rb
Instance Method Summary collapse
-
#initialize(raml) ⇒ View
constructor
A new instance of View.
- #markdown(string) ⇒ Object
- #method_element_id(method, *args) ⇒ Object
- #present?(value) ⇒ Boolean
- #render(template, format) ⇒ Object
Methods included from RamlHelper
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
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.("../templates", __FILE__), format, template, "index.#{format}.erb") template = ERB.new(File.read(template_path)) template.result binding end |