Class: RapiDoc::MethodDoc
- Inherits:
-
Object
- Object
- RapiDoc::MethodDoc
- Defined in:
- lib/rapi_doc/method_doc.rb
Overview
This class holds methods about a doc.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#method ⇒ Object
Returns the value of attribute method.
-
#method_order ⇒ Object
Returns the value of attribute method_order.
-
#name ⇒ Object
Return url if the @name is not set.
-
#outputs ⇒ Object
Returns the value of attribute outputs.
-
#params ⇒ Object
Returns the value of attribute params.
-
#request ⇒ Object
Returns the value of attribute request.
-
#request_header ⇒ Object
Returns the value of attribute request_header.
-
#response ⇒ Object
Returns the value of attribute response.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#url ⇒ Object
Returns the value of attribute url.
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.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rapi_doc/method_doc.rb', line 7 def initialize(resource_name, type, order) @resource_name = resource_name @scope = type @method_order = order @content = "" @request_header = "" @request = "" @response = "" @outputs = {} @params = [] @name = "" @url = "" @method = "" end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def content @content end |
#method ⇒ Object
Returns the value of attribute method.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def method @method end |
#method_order ⇒ Object
Returns the value of attribute method_order.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def method_order @method_order end |
#name ⇒ Object
Return url if the @name is not set.
86 87 88 |
# File 'lib/rapi_doc/method_doc.rb', line 86 def name @name end |
#outputs ⇒ Object
Returns the value of attribute outputs.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def outputs @outputs end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def params @params end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def request @request end |
#request_header ⇒ Object
Returns the value of attribute request_header.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def request_header @request_header end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def response @response end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def scope @scope end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/rapi_doc/method_doc.rb', line 4 def url @url end |
Instance Method Details
#get_binding ⇒ Object
81 82 83 |
# File 'lib/rapi_doc/method_doc.rb', line 81 def get_binding binding end |
#process_line(line, current_scope) ⇒ Object
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rapi_doc/method_doc.rb', line 22 def process_line(line, current_scope) line.strip! #puts "In scope #{current_scope} processing: #{line}" new_scope = current_scope case current_scope when :response if line =~ /::response-end::/ new_scope = :function else @response << line end when :request_header if line =~ /::request_header-end::/ new_scope = :function else @request_header << 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 last_output_key = @outputs.keys.last @outputs[last_output_key] << ERB::Util.html_escape(line) end when :class, :function result = line.scan(/(\w+)\:\:\s*(.*)/) if not result.empty? key, value = result[0] value.strip! case key when "response", "request", "request_header" new_scope = key.to_sym when "output" new_scope = key.to_sym @outputs[value] = '' # add the new output format as a key when "param" @params << value when "url", "name", "method" self.send("#{key}=", 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 |