Class: Command::Not

Inherits:
Object
  • Object
show all
Defined in:
lib/karel/command/not.rb

Instance Method Summary collapse

Constructor Details

#initialize(statement) ⇒ Not

Returns a new instance of Not.



5
6
7
# File 'lib/karel/command/not.rb', line 5

def initialize(statement)
  @statement = statement
end

Instance Method Details

#execute(compass, location, tokens) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/karel/command/not.rb', line 9

def execute(compass, location, tokens)
  response = @statement.execute(compass, location, tokens)
  Response.new(
    compass: response.compass,
    location: response.location,
    operations_count: response.operations_count,
    return_value: !response.return_value,
    tokens: response.tokens
  )
end