class Ellipses::Client::Directive
Constants
- Error
Attributes
commands[R]
server[R]
Public Class Methods
new(lexemes, server)
click to toggle source
# File lib/ellipses/client/directive.rb, line 10 def initialize(lexemes, server) @server = server @commands = build(lexemes) end
Public Instance Methods
execute(**kwargs)
click to toggle source
# File lib/ellipses/client/directive.rb, line 15 def execute(**kwargs) output = [] commands.each do |command| output = command.call(input = output, **kwargs) || input end output end
Private Instance Methods
build(lexemes)
click to toggle source
# File lib/ellipses/client/directive.rb, line 25 def build(lexemes) lexemes.map do |lexeme| name = lexeme.token raise Error, "No such command available: #{name}" unless Commands.available?(name) proto = Commands.proto(name) raise Error, "Wrong number of arguments: #{lexeme.argv}" unless proto.valid?(lexeme.argv) proto.klass.new(lexeme.argv, server) end end