Class: Boxify::Box

Inherits:
Object
  • Object
show all
Includes:
Dimensionable
Defined in:
lib/boxify/box.rb

Instance Attribute Summary collapse

Attributes included from Dimensionable

#depth, #height, #width

Instance Method Summary collapse

Methods included from Dimensionable

#area, #surface_area, #volume

Constructor Details

#initialize(width:, depth:, height:, total_count: 1) ⇒ Box

Returns a new instance of Box.



7
8
9
10
11
12
# File 'lib/boxify/box.rb', line 7

def initialize(width:, depth:, height:, total_count: 1)
  @width = width
  @depth = depth
  @height = height
  @total_count = total_count
end

Instance Attribute Details

#total_countObject

Returns the value of attribute total_count.



5
6
7
# File 'lib/boxify/box.rb', line 5

def total_count
  @total_count
end

Instance Method Details

#rotateObject



18
19
20
21
22
# File 'lib/boxify/box.rb', line 18

def rotate
  temp_width = width
  @width = height
  @height = temp_width
end

#rotatedObject



14
15
16
# File 'lib/boxify/box.rb', line 14

def rotated
  @rotated ||= Box.new(width: height, depth: depth, height: width)
end