Class: RbSnake::Actions::ChangeDirection

Inherits:
Object
  • Object
show all
Defined in:
lib/rb_snake/actions/change_direction.rb

Class Method Summary collapse

Class Method Details

.call(state, window, new_direction:) ⇒ Object



9
10
11
12
13
14
# File 'lib/rb_snake/actions/change_direction.rb', line 9

def call(state, window, new_direction:)
  return unless valid_direction?(state.current_direction, new_direction)

  state.update_direction(new_direction)
  MoveSnake.call(state, window)
end