Class: GrapeDoc::ApiDocumentation

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

Instance Method Summary collapse

Instance Method Details

#add(type, *args) ⇒ Object



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

def add(type,*args)
  self.push(create(type,*args))
end

#build(type, *args) ⇒ Object Also known as: create

Raises:

  • (ArgumentError)


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

def build(type,*args)
  raise(ArgumentError,'invalid type') unless [String,Symbol].any?{ |klass| type.class <= klass }
  return Helpers.constantize("GrapeDoc::ApiDocParts::#{Helpers.camelize(type)}").new(*args)
end

#to_textileObject Also known as: to_s



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

def to_textile
  require 'RedCloth'
  RedCloth.new(self.map{|e| e.to_textile }.join("\n\n"))
end