Class: SpaceInvaders::UBlockContainer
- Defined in:
- lib/space_invaders/blocks/u_block_container.rb
Instance Attribute Summary collapse
-
#u_blocks ⇒ Object
readonly
Returns the value of attribute u_blocks.
Attributes inherited from Base
Instance Method Summary collapse
- #<<(item) ⇒ Object (also: #push, #add)
- #delete(item) ⇒ Object
- #draw ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(app) ⇒ UBlockContainer
constructor
A new instance of UBlockContainer.
- #initialize_u_blocks ⇒ Object
- #update ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(app) ⇒ UBlockContainer
Returns a new instance of UBlockContainer.
9 10 11 12 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 9 def initialize app super initialize_u_blocks end |
Instance Attribute Details
#u_blocks ⇒ Object (readonly)
Returns the value of attribute u_blocks.
7 8 9 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 7 def u_blocks @u_blocks end |
Instance Method Details
#<<(item) ⇒ Object Also known as: push, add
38 39 40 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 38 def <<(item) @u_blocks << item end |
#delete(item) ⇒ Object
34 35 36 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 34 def delete(item) @u_blocks.delete(item) end |
#draw ⇒ Object
18 19 20 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 18 def draw @u_blocks.each {|item| item.draw } end |
#each(&block) ⇒ Object
30 31 32 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 30 def each(&block) @u_blocks.each(&block) end |
#initialize_u_blocks ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 22 def initialize_u_blocks @u_blocks = [ UBlock.new(app, 150, 400), UBlock.new(app, 350, 400), UBlock.new(app, 550, 400) ] end |
#update ⇒ Object
14 15 16 |
# File 'lib/space_invaders/blocks/u_block_container.rb', line 14 def update @u_blocks.each { |item| item.update } end |