Class: Boxify::SpaceCollection
- Inherits:
-
Object
- Object
- Boxify::SpaceCollection
- Extended by:
- Forwardable
- Defined in:
- lib/boxify/space.rb
Instance Attribute Summary collapse
-
#spaces ⇒ Object
readonly
Returns the value of attribute spaces.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(spaces:) ⇒ SpaceCollection
constructor
A new instance of SpaceCollection.
Constructor Details
#initialize(spaces:) ⇒ SpaceCollection
Returns a new instance of SpaceCollection.
19 20 21 |
# File 'lib/boxify/space.rb', line 19 def initialize(spaces:) @spaces = spaces end |
Instance Attribute Details
#spaces ⇒ Object (readonly)
Returns the value of attribute spaces.
15 16 17 |
# File 'lib/boxify/space.rb', line 15 def spaces @spaces end |
Class Method Details
.find_spaces_within_space(space:, box:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/boxify/space.rb', line 23 def self.find_spaces_within_space(space:, box:) spaces = [] if space.depth - box.depth > 0 spaces.push(Space.new(depth: space.depth - box.depth, width: space.width, height: box.height)) end if space.width - box.width > 0 spaces.push(Space.new(depth: box.depth, width: space.width - box.width, height: box.height)) end new(spaces: spaces) end |