Class: RestApiDoc::MethodDoc
- Inherits:
-
Object
- Object
- RestApiDoc::MethodDoc
- Defined in:
- lib/restapi_doc/method_doc.rb
Instance Attribute Summary collapse
-
#account_password_required ⇒ Object
Returns the value of attribute account_password_required.
-
#content ⇒ Object
Returns the value of attribute content.
-
#defname ⇒ Object
Returns the value of attribute defname.
-
#http_responses ⇒ Object
Returns the value of attribute http_responses.
-
#method_order ⇒ Object
Returns the value of attribute method_order.
-
#output ⇒ Object
Returns the value of attribute output.
-
#params ⇒ Object
Returns the value of attribute params.
-
#request ⇒ Object
Returns the value of attribute request.
-
#request_url ⇒ Object
Returns the value of attribute request_url.
-
#requires_authentication ⇒ Object
Returns the value of attribute requires_authentication.
-
#response ⇒ Object
Returns the value of attribute response.
-
#response_formats ⇒ Object
Returns the value of attribute response_formats.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #get_binding ⇒ Object
-
#initialize(resource_name, type, order) ⇒ MethodDoc
constructor
A new instance of MethodDoc.
- #process_line(line, current_scope) ⇒ Object
Constructor Details
#initialize(resource_name, type, order) ⇒ MethodDoc
Returns a new instance of MethodDoc.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/restapi_doc/method_doc.rb', line 6 def initialize(resource_name, type, order) @resource_name = resource_name @scope = type @method_order = order @content = "" @request = "" @response = "" @output = "" @params = [] @response_formats = [] @http_responses= [] @requires_authentication = "No" @account_password_required = "No" @defname = nil @request_url = nil end |
Instance Attribute Details
#account_password_required ⇒ Object
Returns the value of attribute account_password_required.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def account_password_required @account_password_required end |
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def content @content end |
#defname ⇒ Object
Returns the value of attribute defname.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def defname @defname end |
#http_responses ⇒ Object
Returns the value of attribute http_responses.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def http_responses @http_responses end |
#method_order ⇒ Object
Returns the value of attribute method_order.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def method_order @method_order end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def output @output end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def params @params end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def request @request end |
#request_url ⇒ Object
Returns the value of attribute request_url.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def request_url @request_url end |
#requires_authentication ⇒ Object
Returns the value of attribute requires_authentication.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def requires_authentication @requires_authentication end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def response @response end |
#response_formats ⇒ Object
Returns the value of attribute response_formats.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def response_formats @response_formats end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/restapi_doc/method_doc.rb', line 4 def scope @scope end |
Instance Method Details
#get_binding ⇒ Object
79 80 81 |
# File 'lib/restapi_doc/method_doc.rb', line 79 def get_binding binding end |
#process_line(line, current_scope) ⇒ Object
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/restapi_doc/method_doc.rb', line 23 def process_line(line, current_scope) new_scope = current_scope case current_scope when :response if line =~ /::response-end::/ new_scope = :function else @response << line end when :request if line =~ /::request-end::/ new_scope = :function else @request << line end when :output # append output if line =~ /::output-end::/ new_scope = :function else @output << line end when :class, :function result = line.scan(/(\w+)\:\:\s*(.+)/) if not result.empty? key, value = result[0] case key when "response", "request" new_scope = key.to_sym when "output" new_scope = key.to_sym when "param" @params << value when "http_response" @http_responses << value when "response_format" @response_formats << value when "requires_authentication" @requires_authentication = value when "request_url" @request_url = value when "account_password_required" @account_password_required = value else # user wants this new shiny variable whose name is the key with value = value instance_variable_set("@#{key}".to_sym, value) define_singleton_method(key.to_sym) { value } # define accessor for the templates to read it end else # add line to block @content << line end else raise ParsingException, "logic error: unknown current scope #{current_scope}" end new_scope end |