Class: Sinatra::Chiro::Documentation
- Inherits:
-
Object
- Object
- Sinatra::Chiro::Documentation
- Defined in:
- lib/sinatra/chiro/document.rb
Instance Attribute Summary collapse
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
Instance Method Summary collapse
- #document(env) ⇒ Object
-
#initialize(endpoints) ⇒ Documentation
constructor
A new instance of Documentation.
- #routes ⇒ Object
Constructor Details
#initialize(endpoints) ⇒ Documentation
Returns a new instance of Documentation.
7 8 9 |
# File 'lib/sinatra/chiro/document.rb', line 7 def initialize(endpoints) @endpoints = endpoints end |
Instance Attribute Details
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
5 6 7 |
# File 'lib/sinatra/chiro/document.rb', line 5 def endpoints @endpoints end |
Instance Method Details
#document(env) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/sinatra/chiro/document.rb', line 11 def document(env) _, path = env['sinatra.route'].split endpoint = endpoints.select { |d| d.path == path}.flatten.first raise "Path #{path} doesn't have any docs" unless endpoint [[endpoints[0].appname, [endpoint]]] end |
#routes ⇒ Object
18 19 20 |
# File 'lib/sinatra/chiro/document.rb', line 18 def routes [endpoints[0].appname, endpoints] end |