Class: CabbageDoc::Action
- Inherits:
-
Object
- Object
- CabbageDoc::Action
- Includes:
- Parser
- Defined in:
- lib/cabbage_doc/action.rb
Constant Summary collapse
- METHODS =
%w(GET POST PUT DELETE).freeze
- METHODS_REGEXP =
METHODS.join('|').freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#visibility ⇒ Object
readonly
Returns the value of attribute visibility.
Instance Method Summary collapse
-
#initialize ⇒ Action
constructor
A new instance of Action.
- #param?(key) ⇒ Boolean
- #parse(text, tag = TAG) ⇒ Object
- #valid? ⇒ Boolean
Methods included from Parser
included, #parse_option, #parse_templates
Constructor Details
#initialize ⇒ Action
Returns a new instance of Action.
10 11 12 13 14 |
# File 'lib/cabbage_doc/action.rb', line 10 def initialize @parameters = [] @examples = [] @visibility = VISIBILITY.first end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def description @description end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def examples @examples end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def label @label end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def parameters @parameters end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def path @path end |
#visibility ⇒ Object (readonly)
Returns the value of attribute visibility.
8 9 10 |
# File 'lib/cabbage_doc/action.rb', line 8 def visibility @visibility end |
Instance Method Details
#param?(key) ⇒ Boolean
34 35 36 |
# File 'lib/cabbage_doc/action.rb', line 34 def param?(key) @parameters.any? { |parameter| parameter.name =~ /#{key}/ } end |
#parse(text, tag = TAG) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cabbage_doc/action.rb', line 16 def parse(text, tag = TAG) @method, @path = parse_method_and_path(text) return unless valid? @name = parse_name(text) @label = parse_label(text) @description = parse_description(text) @visibility = parse_visibility(text) @parameters, @examples = parse_parameters_and_examples(text) valid? end |
#valid? ⇒ Boolean
30 31 32 |
# File 'lib/cabbage_doc/action.rb', line 30 def valid? @method && @path end |