Class: Lookbook::ParamTag
- Defined in:
- lib/lookbook/tags/param_tag.rb
Constant Summary collapse
- VALUE_TYPE_MATCHER =
/^(\[\s?([A-Z]{1}\w+)\s?\])/- DESCRIPTION_MATCHER =
/"(.*[^\\])"$/
Instance Attribute Summary collapse
-
#tag_args ⇒ Object
readonly
Returns the value of attribute tag_args.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(text) ⇒ ParamTag
constructor
A new instance of ParamTag.
- #input ⇒ Object
- #value_default ⇒ Object
- #value_type ⇒ Object
Methods inherited from YardTag
Constructor Details
#initialize(text) ⇒ ParamTag
Returns a new instance of ParamTag.
8 9 10 11 12 |
# File 'lib/lookbook/tags/param_tag.rb', line 8 def initialize(text) @name, text_without_name = extract_name(text) @tag_args = parse_tag_body(text_without_name) super("param", tag_args[:rest], nil, @name) end |
Instance Attribute Details
#tag_args ⇒ Object (readonly)
Returns the value of attribute tag_args.
6 7 8 |
# File 'lib/lookbook/tags/param_tag.rb', line 6 def tag_args @tag_args end |
Instance Method Details
#description ⇒ Object
18 19 20 |
# File 'lib/lookbook/tags/param_tag.rb', line 18 def description tag_args[:description] end |
#input ⇒ Object
14 15 16 |
# File 'lib/lookbook/tags/param_tag.rb', line 14 def input tag_args[:input]&.downcase&.tr("_", "-") end |
#value_default ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/lookbook/tags/param_tag.rb', line 26 def value_default default_value_parts = object.parameters.find { |parts| parts[0].chomp(":") == name } if default_value_parts object.instance_eval(default_value_parts[1]) else raise ParserError.new "Unknown method parameter '#{name}'" end end |
#value_type ⇒ Object
22 23 24 |
# File 'lib/lookbook/tags/param_tag.rb', line 22 def value_type tag_args[:value_type]&.downcase end |