Class: MakeTaggable::GenericParser
- Inherits:
-
Object
- Object
- MakeTaggable::GenericParser
- Defined in:
- lib/make_taggable/generic_parser.rb
Overview
The base class for tag parsers, and a working parser in its own right: it splits on commas and ignores surrounding whitespace.
Subclass it to accept a different format, and point Configuration#default_parser
at the subclass, or pass it per call as the :parser option to TagList#add.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(tag_list) ⇒ MakeTaggable::GenericParser
constructor
Holds the input until #parse is called.
-
#parse ⇒ MakeTaggable::TagList
Splits the input on commas.
Constructor Details
#initialize(tag_list) ⇒ MakeTaggable::GenericParser
Holds the input until #parse is called.
27 28 29 |
# File 'lib/make_taggable/generic_parser.rb', line 27 def initialize(tag_list) @tag_list = tag_list end |
Instance Method Details
#parse ⇒ MakeTaggable::TagList
Splits the input on commas.
39 40 41 42 43 |
# File 'lib/make_taggable/generic_parser.rb', line 39 def parse TagList.new.tap do |tag_list| tag_list.add @tag_list.split(",").map(&:strip).reject(&:empty?) end end |