Class: Yarddown::Endpoint
- Inherits:
-
Object
- Object
- Yarddown::Endpoint
- Defined in:
- lib/yardbird/endpoint.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#docstring ⇒ Object
Returns the value of attribute docstring.
-
#example ⇒ Object
Returns the value of attribute example.
-
#example_params ⇒ Object
Returns the value of attribute example_params.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #doc_path ⇒ Object
-
#initialize(yardoc) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #parse ⇒ Object
Constructor Details
#initialize(yardoc) ⇒ Endpoint
Returns a new instance of Endpoint.
16 17 18 19 |
# File 'lib/yardbird/endpoint.rb', line 16 def initialize(yardoc) @yardoc = yardoc parse end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def category @category end |
#docstring ⇒ Object
Returns the value of attribute docstring.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def docstring @docstring end |
#example ⇒ Object
Returns the value of attribute example.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def example @example end |
#example_params ⇒ Object
Returns the value of attribute example_params.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def example_params @example_params end |
#method ⇒ Object
Returns the value of attribute method.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def method @method end |
#params ⇒ Object
Returns the value of attribute params.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def path @path end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/yardbird/endpoint.rb', line 7 def status @status end |
Instance Method Details
#doc_path ⇒ Object
55 56 57 |
# File 'lib/yardbird/endpoint.rb', line 55 def doc_path "#{path}.#{method}" end |
#parse ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/yardbird/endpoint.rb', line 21 def parse self.method = @yardoc.(:http)[0].try(:text) self.method ||= 'GET' self.path = @yardoc.(:path)[0].try(:text) self.docstring = @yardoc.docstring if @yardoc.(:category).any? self.category = @yardoc.(:category)[0].try(:text) else self.category = 'Uncategorized' end self.status = @yardoc.(:status).map do |s| { code: s.name.to_i, doc: s.text } end self.status = self.status.sort_by { |s| s[:code] } self.params = [@yardoc.(:required), @yardoc.(:optional)].flatten.map do |param| { name: param.name, types: param.types, doc: param.text, type: param.tag_name } end self.example = @yardoc.(:example)[0].try(:name) self.example ||= self.path if @yardoc.(:example)[0].try(:text) self.example_params = @yardoc.(:example)[0].text.split.map {|p| p.split(':')} end end |