Class: ApiExplorer::Request
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#excluded_shared_headers ⇒ Object
Returns the value of attribute excluded_shared_headers.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(method, path, params = [], headers = [], description = "", excluded_shared_headers = []) ⇒ Request
constructor
A new instance of Request.
- #title ⇒ Object
- #url ⇒ Object
- #url_params ⇒ Object
- #url_segments ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(method, path, params = [], headers = [], description = "", excluded_shared_headers = []) ⇒ Request
Returns a new instance of Request.
5 6 7 8 9 10 11 12 13 |
# File 'lib/api_explorer/request.rb', line 5 def initialize(method, path, params = [], headers = [], description = "", excluded_shared_headers = []) super nil, nil, path self.method = method.to_s self.params = Array(params) self.headers = Array(headers) self.description = description self.excluded_shared_headers = Array(excluded_shared_headers) end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/api_explorer/request.rb', line 3 def description @description end |
#excluded_shared_headers ⇒ Object
Returns the value of attribute excluded_shared_headers.
3 4 5 |
# File 'lib/api_explorer/request.rb', line 3 def excluded_shared_headers @excluded_shared_headers end |
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/api_explorer/request.rb', line 3 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'lib/api_explorer/request.rb', line 3 def method @method end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/api_explorer/request.rb', line 3 def params @params end |
Instance Method Details
#title ⇒ Object
33 34 35 |
# File 'lib/api_explorer/request.rb', line 33 def title "#{method.upcase} #{path}" end |
#url ⇒ Object
15 16 17 |
# File 'lib/api_explorer/request.rb', line 15 def url full_path end |
#url_params ⇒ Object
19 20 21 |
# File 'lib/api_explorer/request.rb', line 19 def url_params path.scan(/:[a-zA-Z_\-]+/).map { |s| s[1..s.size] } end |
#url_segments ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/api_explorer/request.rb', line 23 def url_segments path.scan(/(:[a-zA-Z_\-]+)|([^:]+)/).map do |param, normal| if param [:param, param[1..param.size]] else [:normal, normal] end end end |