Class: RubyLint::Docstring::Mapping
- Inherits:
-
Object
- Object
- RubyLint::Docstring::Mapping
- Defined in:
- lib/ruby-lint/docstring/mapping.rb
Overview
Mapping is a small data container for storing docstring tags separately and optionally by their names (e.g. for parameter tags).
Constant Summary
- TAG_METHODS =
Hash containing the known tag classes and their callback methods.
{ ParamTag => :on_param_tag, ReturnTag => :on_return_tag }
Instance Attribute Summary collapse
-
#param_tags ⇒ Hash
readonly
-
#return_tag ⇒ RubyLint::Docstring::ReturnTag
readonly
Instance Method Summary collapse
-
#initialize(tags = []) ⇒ Mapping
constructor
A new instance of Mapping.
-
#on_param_tag(tag) ⇒ Object
private
-
#on_return_tag(tag) ⇒ Object
private
Constructor Details
#initialize(tags = []) ⇒ Mapping
Returns a new instance of Mapping
30 31 32 33 34 35 36 |
# File 'lib/ruby-lint/docstring/mapping.rb', line 30 def initialize( = []) @param_tags = {} .each do |tag| send(TAG_METHODS[tag.class], tag) end end |
Instance Attribute Details
#param_tags ⇒ Hash (readonly)
14 15 16 17 18 19 20 21 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 |
# File 'lib/ruby-lint/docstring/mapping.rb', line 14 class Mapping attr_reader :param_tags, :return_tag ## # Hash containing the known tag classes and their callback methods. # # @return [Hash] # TAG_METHODS = { ParamTag => :on_param_tag, ReturnTag => :on_return_tag } ## # @param [Array] tags # def initialize( = []) @param_tags = {} .each do |tag| send(TAG_METHODS[tag.class], tag) end end private ## # @param [RubyLint::Docstring::ParamTag] tag # def on_param_tag(tag) @param_tags[tag.name] = tag end ## # @param [RubyLint::Docstring::ReturnTag] tag # def on_return_tag(tag) @return_tag = tag end end |
#return_tag ⇒ RubyLint::Docstring::ReturnTag (readonly)
14 15 16 17 18 19 20 21 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 |
# File 'lib/ruby-lint/docstring/mapping.rb', line 14 class Mapping attr_reader :param_tags, :return_tag ## # Hash containing the known tag classes and their callback methods. # # @return [Hash] # TAG_METHODS = { ParamTag => :on_param_tag, ReturnTag => :on_return_tag } ## # @param [Array] tags # def initialize( = []) @param_tags = {} .each do |tag| send(TAG_METHODS[tag.class], tag) end end private ## # @param [RubyLint::Docstring::ParamTag] tag # def on_param_tag(tag) @param_tags[tag.name] = tag end ## # @param [RubyLint::Docstring::ReturnTag] tag # def on_return_tag(tag) @return_tag = tag end end |
Instance Method Details
#on_param_tag(tag) ⇒ Object (private)
43 44 45 |
# File 'lib/ruby-lint/docstring/mapping.rb', line 43 def on_param_tag(tag) @param_tags[tag.name] = tag end |
#on_return_tag(tag) ⇒ Object (private)
50 51 52 |
# File 'lib/ruby-lint/docstring/mapping.rb', line 50 def on_return_tag(tag) @return_tag = tag end |