Class: CabbageDoc::Parameter
- Inherits:
-
Object
- Object
- CabbageDoc::Parameter
- Includes:
- Parser
- Defined in:
- lib/cabbage_doc/parameter.rb
Constant Summary collapse
- TYPES =
i(numeric decimal integer string id enumeration array date time hash)
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#type_label ⇒ Object
readonly
Returns the value of attribute type_label.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize ⇒ Parameter
constructor
A new instance of Parameter.
- #parse(text, tag = TAG) ⇒ Object
- #valid? ⇒ Boolean
Methods included from Parser
included, #parse_option, #parse_templates
Constructor Details
#initialize ⇒ Parameter
Returns a new instance of Parameter.
9 10 11 |
# File 'lib/cabbage_doc/parameter.rb', line 9 def initialize @values = [] end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def default @default end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def type @type end |
#type_label ⇒ Object (readonly)
Returns the value of attribute type_label.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def type_label @type_label end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
7 8 9 |
# File 'lib/cabbage_doc/parameter.rb', line 7 def values @values end |
Instance Method Details
#parse(text, tag = TAG) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cabbage_doc/parameter.rb', line 13 def parse(text, tag = TAG) m = text.match(/^(.*?\s+\(.*?\).*?)\s+-\s+(.*?)$/) return false unless m @name, @type_label, @required = parse_name_type_required(m[1].strip) @type = @type_label.downcase.to_sym if @type_label @required = !!@required @label, @default, @values = parse_label_default_values(m[2].strip) @values ||= [] valid? end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/cabbage_doc/parameter.rb', line 28 def valid? @type && TYPES.include?(@type) end |