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

#br(int = 1) ⇒ Object



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

def br(int=1)
  raise unless int.class <= Integer
  int.times{self.push(ApiDocParts::Br.new("\n"))}
end

#create(type, *args) ⇒ Object

Raises:

  • (ArgumentError)


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

def create(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



19
20
21
22
# File 'lib/grape/doc/doc_class.rb', line 19

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