# frozen_string_literal: true module ConvenientService module Utils module String class Split < Support::Command ## # @!attribute [r] string # @return [String] # attr_reader :string ## # @!attribute [r] delimiters # @return [Array] # attr_reader :delimiters ## # @param string [#to_s] # @param delimiters [Array] # @return [void] # def initialize(string, *delimiters) @string = string.to_s @delimiters = delimiters end ## # @return [String] # # @internal # https://stackoverflow.com/a/51380514/12201472 # def call string.split(::Regexp.union(delimiters)) end end end end end