Class: EasyTags::Parsers::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_tags/parsers/default.rb

Overview

Default parser for [String] -> [Array] conversion

Class Method Summary collapse

Class Method Details

.parse(tag_list_string) ⇒ Array<String>

Returns a new TagList using the given tag string.

Example:

EasyTags::Parsers::Default.parse('One , Two,  Three')
['One', 'Two', 'Three']

Parameters:

  • tag_list_string (String)

Returns:

  • (Array<String>)

14
15
16
17
18
# File 'lib/easy_tags/parsers/default.rb', line 14

def parse(tag_list_string)
  return [] if tag_list_string.to_s.empty?

  tag_list_string.to_s.split(/,/).map(&:strip)
end