Class: Autodoc::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/autodoc/document.rb

Defined Under Namespace

Classes: Parameter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Document

Returns a new instance of Document.



14
15
16
# File 'lib/autodoc/document.rb', line 14

def initialize(context)
  @context = context
end

Class Method Details

.render(*args) ⇒ Object



10
11
12
# File 'lib/autodoc/document.rb', line 10

def self.render(*args)
  new(*args).render
end

Instance Method Details

#identifierObject



33
34
35
# File 'lib/autodoc/document.rb', line 33

def identifier
  title.gsub(" ", "-").gsub(/[:\/]/, "").downcase
end

#pathnameObject



18
19
20
21
22
23
# File 'lib/autodoc/document.rb', line 18

def pathname
  @path ||= begin
    payload = @context.example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
    Pathname.new(Autodoc.configuration.path) + payload
  end
end

#renderObject



25
26
27
# File 'lib/autodoc/document.rb', line 25

def render
  ERB.new(Autodoc.configuration.template, nil, "-").result(binding)
end

#titleObject



29
30
31
# File 'lib/autodoc/document.rb', line 29

def title
  "#{method} #{path}"
end