Class: Falling::Area
- Inherits:
-
Object
- Object
- Falling::Area
- Defined in:
- lib/falling/area.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(width:, height:) ⇒ Area
constructor
A new instance of Area.
- #to_a ⇒ Object
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
#height ⇒ Object (readonly)
Returns the value of attribute height.
3 4 5 |
# File 'lib/falling/area.rb', line 3 def height @height end |
#width ⇒ Object (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_a ⇒ Object
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 |