Class: GrapeDoc::Generator
- Inherits:
-
Object
- Object
- GrapeDoc::Generator
- Defined in:
- lib/grape/doc/generator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Generator
constructor
A new instance of Generator.
- #save ⇒ Object (also: #save!)
Constructor Details
#initialize(opts = {}) ⇒ Generator
Returns a new instance of Generator.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/grape/doc/generator.rb', line 6 def initialize(opts={}) raise(ArgumentError,'invalid options given') unless opts.class <= Hash @options = { 'format' => 'html', 'path' => File.join(Helpers.doc_folder_path,'api_doc') }.merge(opts.reduce({}){|m,o| m.merge!(o[0].to_s => o[1]) ;m}) self.['path'] = self.['path'].to_s.sub(/\..*$/,'') process_head process_endpoints process_table_of_content end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/grape/doc/generator.rb', line 5 def @options end |
Instance Method Details
#save ⇒ Object Also known as: save!
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/grape/doc/generator.rb', line 21 def save case @options['format'].to_s.downcase when /redmine/,/textile/ File.write self.['path'] + '.textile', document.to_textile else File.write self.['path'] + '.html', document.to_textile.to_html end true;rescue;false end |