module Extras::String
Public Instance Methods
to_a(char: "\s", strip: true)
click to toggle source
Note: This method has support for “char” escaping to prevent splits. Split a string into an array.
# File lib/extras/string.rb, line 25 def to_a(char: "\s", strip: true) escaped = char.regexp_escape split(/(?<!\)#{escaped}/).map do |v| strip ? v.gsub(/\#{escaped}/, char) : v end end