Class: Motel::MovementStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/motel/movement_strategy.rb

Overview

MovementStrategy subclasses define the rules and params which a location changes its position.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ MovementStrategy

Returns a new instance of MovementStrategy.



18
19
20
21
22
# File 'lib/motel/movement_strategy.rb', line 18

def initialize(args = {})
   @step_delay = 1

   @step_delay = args[:step_delay] if args.has_key?(:step_delay) && !args[:step_delay].nil?
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



14
15
16
# File 'lib/motel/movement_strategy.rb', line 14

def id
  @id
end

#step_delayObject

Returns the value of attribute step_delay.



16
17
18
# File 'lib/motel/movement_strategy.rb', line 16

def step_delay
  @step_delay
end

#typeObject

Returns the value of attribute type.



14
15
16
# File 'lib/motel/movement_strategy.rb', line 14

def type
  @type
end

Instance Method Details

#move(location, elapsed_seconds) ⇒ Object

default movement strategy is to do nothing



25
26
# File 'lib/motel/movement_strategy.rb', line 25

def move(location, elapsed_seconds)
end