Class: Falling::Area

Inherits:
Object
  • Object
show all
Defined in:
lib/falling/area.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:) ⇒ Area

Returns a new instance of Area.



6
7
8
9
10
# File 'lib/falling/area.rb', line 6

def initialize(width:,
               height:)
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



3
4
5
# File 'lib/falling/area.rb', line 3

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



3
4
5
# File 'lib/falling/area.rb', line 3

def width
  @width
end

Instance Method Details

#to_aObject



12
13
14
15
16
17
# File 'lib/falling/area.rb', line 12

def to_a
  @garbage ||=
    (1..height).map do
      (1..width).map { %w(# . . .).sample }.join
    end
end