Class: EasyTags::TagList
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- EasyTags::TagList
- Defined in:
- lib/easy_tags/tag_list.rb
Overview
Represents a tag list
Instance Method Summary collapse
-
#add(*names) ⇒ Object
Add tags to the tag_list.
-
#initialize(*args, generator: EasyTags.generator, parser: EasyTags.parser) ⇒ TagList
constructor
A new instance of TagList.
-
#remove(value) ⇒ Object
Remove item from list.
-
#to_s ⇒ Object
Transform the tag_list into a tag string.
Constructor Details
#initialize(*args, generator: EasyTags.generator, parser: EasyTags.parser) ⇒ TagList
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/easy_tags/tag_list.rb', line 4 def initialize( *args, generator: EasyTags.generator, parser: EasyTags.parser ) self.generator = generator self.parser = parser super([]) add(*args) end |
Instance Method Details
#add(*names) ⇒ Object
Add tags to the tag_list. Duplicate or blank tags will be ignored.
Example:
tag_list.add('Fun', 'Happy')
20 21 22 |
# File 'lib/easy_tags/tag_list.rb', line 20 def add(*names) filter(names).each { |filtered_name| push(filtered_name) unless include?(filtered_name) } end |
#remove(value) ⇒ Object
Remove item from list
Example:
tag_list.remove('Issues')
33 34 35 |
# File 'lib/easy_tags/tag_list.rb', line 33 def remove(value) __getobj__.delete(value) end |
#to_s ⇒ Object
Transform the tag_list into a tag string
25 26 27 |
# File 'lib/easy_tags/tag_list.rb', line 25 def to_s generator.generate(self) end |