Class: ActsAsTaggableOn::GenericParser

Inherits:
Object
  • Object
show all
Defined in:
lib/acts-as-taggable-on/generic_parser.rb

Overview

Returns a new TagList using the given tag string.

Example: tag_list = ActsAsTaggableOn::GenericParser.new.parse(“One , Two, Three”) tag_list # [“One”, “Two”, “Three”]

Direct Known Subclasses

DefaultParser

Instance Method Summary collapse

Constructor Details

#initialize(tag_list) ⇒ GenericParser

Returns a new instance of GenericParser.



11
12
13
# File 'lib/acts-as-taggable-on/generic_parser.rb', line 11

def initialize(tag_list)
  @tag_list = tag_list
end

Instance Method Details

#parseObject



15
16
17
18
19
# File 'lib/acts-as-taggable-on/generic_parser.rb', line 15

def parse
  TagList.new.tap do |tag_list|
    tag_list.add @tag_list.split(',').map(&:strip).reject(&:empty?)
  end
end