Class: GrapeDoc::ApiDocParts::TOC

Inherits:
Object
  • Object
show all
Defined in:
lib/grape/doc/doc_class/header.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TOC

Returns a new instance of TOC.



10
11
12
# File 'lib/grape/doc/doc_class/header.rb', line 10

def initialize(*args)
  headers.push(*args)
end

Instance Method Details

#add_header(header_obj) ⇒ Object



14
15
16
# File 'lib/grape/doc/doc_class/header.rb', line 14

def add_header(header_obj)
  headers.push(header_obj)
end

#clearObject



27
28
29
# File 'lib/grape/doc/doc_class/header.rb', line 27

def clear
  headers.clear
end

#headersObject



6
7
8
# File 'lib/grape/doc/doc_class/header.rb', line 6

def headers
  @headers ||= []
end

#to_textileObject



18
19
20
21
22
23
24
25
# File 'lib/grape/doc/doc_class/header.rb', line 18

def to_textile
  headers.map { |header_obj|
    [
        '*' * header_obj.markdown.scan(/\d+$/)[0].to_i,
        " \"#{header_obj.to_s}\":##{header_obj.instance_variable_get(:@opts)['id']}"
    ].join
  }.join("\n") + "\n\n"
end