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.



9
10
11
# File 'lib/acts_as_taggable_on/generic_parser.rb', line 9

def initialize(tag_list)
  @tag_list = tag_list
end

Instance Method Details

#parseObject



13
14
15
16
17
# File 'lib/acts_as_taggable_on/generic_parser.rb', line 13

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