Module: SpaceInvaders::Fireable

Included in:
InvadersContainer, Ship
Defined in:
lib/space_invaders/behaviors/fireable.rb

Instance Method Summary collapse

Instance Method Details

#bullet_collectionObject Also known as: bullets



7
8
9
# File 'lib/space_invaders/behaviors/fireable.rb', line 7

def bullet_collection
  @bullet_collection ||= BulletCollection.new
end

#bullet_offset_speedObject



30
31
32
# File 'lib/space_invaders/behaviors/fireable.rb', line 30

def bullet_offset_speed
  5
end

#bullets_going_down?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/space_invaders/behaviors/fireable.rb', line 26

def bullets_going_down?
  true
end

#fire!Object



13
14
15
16
# File 'lib/space_invaders/behaviors/fireable.rb', line 13

def fire!
  bullet = Bullet.new(shooter, bullets_going_down?, bullet_collection, bullet_offset_speed)
  sound.play
end

#shooterObject

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/space_invaders/behaviors/fireable.rb', line 18

def shooter
  raise NotImplementedError.new("You must implement the inherited shooter method")
end

#soundObject

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/space_invaders/behaviors/fireable.rb', line 22

def sound
  raise NotImplementedError.new("You must implement the inherited sound method")
end