Class: YARD::Tags::Tag
- Inherits:
-
Object
- Object
- YARD::Tags::Tag
- Defined in:
- lib/yard/tags/tag.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
- #name ⇒ String?
-
#object ⇒ CodeObjects::Base
The associated object.
-
#tag_name ⇒ String
The name of the tag.
- #text ⇒ String?
- #types ⇒ Array<String>?
Instance Method Summary collapse
-
#explain_types ⇒ String?
Provides a plain English summary of the type specification, or nil if no types are provided or parsable.
-
#initialize(tag_name, text, types = nil, name = nil) ⇒ Tag
constructor
Creates a new tag object with a tag name and text.
-
#type ⇒ String
Convenience method to access the first type specified.
Constructor Details
#initialize(tag_name, text, types = nil, name = nil) ⇒ Tag
Creates a new tag object with a tag name and text. Optionally, formally declared types and a key name can be specified.
Types are mainly for meta tags that rely on type information, such as param, return, etc.
Key names are for tags that declare meta data for a specific key or name, such as param, raise, etc.
45 46 47 48 49 50 |
# File 'lib/yard/tags/tag.rb', line 45 def initialize(tag_name, text, types = nil, name = nil) @tag_name = tag_name.to_s @text = text @name = name @types = (types ? [types].flatten.compact : nil) end |
Instance Attribute Details
#object ⇒ CodeObjects::Base
Returns the associated object.
30 31 32 |
# File 'lib/yard/tags/tag.rb', line 30 def object @object end |
#tag_name ⇒ String
Returns the name of the tag.
15 16 17 |
# File 'lib/yard/tags/tag.rb', line 15 def tag_name @tag_name end |
Instance Method Details
#explain_types ⇒ String?
Provides a plain English summary of the type specification, or nil if no types are provided or parsable.
66 67 68 69 |
# File 'lib/yard/tags/tag.rb', line 66 def explain_types return nil if !types || types.empty? TypesExplainer.explain(*types) end |
#type ⇒ String
Convenience method to access the first type specified. This should mainly be used for tags that only specify one type.
57 58 59 |
# File 'lib/yard/tags/tag.rb', line 57 def type types.first end |