class Toys::Loader::DelimiterHandler
An object that handles name delimiting.
@private
Public Class Methods
new(extra_delimiters)
click to toggle source
# File lib/toys/loader.rb, line 724 def initialize(extra_delimiters) unless %r{^[[:space:]./:]*$}.match?(extra_delimiters) raise ::ArgumentError, "Illegal delimiters in #{extra_delimiters.inspect}" end chars = ::Regexp.escape(extra_delimiters.chars.uniq.join) @delimiters = ::Regexp.new("[[:space:]#{chars}]") end
Public Instance Methods
find_orig_prefix(args)
click to toggle source
# File lib/toys/loader.rb, line 736 def find_orig_prefix(args) first_split = (args.first || "").split(@delimiters) if first_split.size > 1 args = first_split + args.slice(1..-1) return [first_split, args] end orig_prefix = args.take_while { |arg| !arg.start_with?("-") } [orig_prefix, args] end
split_path(str)
click to toggle source
# File lib/toys/loader.rb, line 732 def split_path(str) str.split(@delimiters) end