Sha256: c4cd75bc84e4916ffa72c294cc2b44bf1b074fb7acd4bb0ade3ea99d5ae41db7
Contents?: true
Size: 957 Bytes
Versions: 4
Compression:
Stored size: 957 Bytes
Contents
class Usher class Splitter def self.for_delimiters(delimiters_array) delimiters = Delimiters.new(delimiters_array) delimiters.any?{|d| d.size > 1} ? MultiCharacterSplitterInstance.new(delimiters) : SingleCharacterSplitterInstance.new(delimiters) end class SingleCharacterSplitterInstance def initialize(delimiters) @url_split_regex = Regexp.new("[^#{delimiters.regexp_char_class}]+|[#{delimiters.regexp_char_class}]") end def split(path) path.scan(@url_split_regex) end end class MultiCharacterSplitterInstance def initialize(delimiters) @delimiters = delimiters end def split(path) split_path = path.split(delimiters_regexp) split_path.reject!{|s| s.empty? } split_path end protected def delimiters_regexp @delimiters.regexp end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
usher-0.7.5 | lib/usher/splitter.rb |
usher-0.7.4 | lib/usher/splitter.rb |
usher-0.7.3 | lib/usher/splitter.rb |
usher-0.7.2 | lib/usher/splitter.rb |