Sha256: 07c6ad0b1d0e0ceaceafd96ec6e95157d5370bf17e72ad4eb511d872f4c655f9
Contents?: true
Size: 641 Bytes
Versions: 13
Compression:
Stored size: 641 Bytes
Contents
class Cl module Runner class Multi attr_reader :name, :cmds def initialize(name, *args) @name = name @cmds = build(group(args)) end def run cmds.map(&:run) end private def group(args, cmds = []) args.flatten.map(&:to_s).inject([[]]) do |cmds, arg| cmd = Cmd.registered?(arg) ? Cmd[arg] : nil cmd ? cmds << [cmd] : cmds.last << arg cmds.reject(&:empty?) end end def build(cmds) cmds.map do |(cmd, *args)| cmd.new(name, args) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems