Class: Ellipses::Client::Directive

Inherits:
Object
  • Object
show all
Defined in:
lib/ellipses/client/directive.rb

Constant Summary collapse

Error =
Class.new Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lexemes, server) ⇒ Directive

Returns a new instance of Directive.



10
11
12
13
# File 'lib/ellipses/client/directive.rb', line 10

def initialize(lexemes, server)
  @server   = server
  @commands = build(lexemes)
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



8
9
10
# File 'lib/ellipses/client/directive.rb', line 8

def commands
  @commands
end

#serverObject (readonly)

Returns the value of attribute server.



8
9
10
# File 'lib/ellipses/client/directive.rb', line 8

def server
  @server
end

Instance Method Details

#execute(**kwargs) ⇒ Object



15
16
17
18
19
20
21
# 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