Class: BoxPacker::Dimensions
- Inherits:
-
Vector
- Object
- Vector
- BoxPacker::Dimensions
show all
- Defined in:
- lib/box_packer/dimensions.rb
Instance Attribute Summary
Attributes inherited from Vector
#x, #y, #z
Instance Method Summary
collapse
Methods inherited from Vector
#+, #-, #==, [], #depth, #eql?, #height, #initialize, #to_a, #width
Instance Method Details
#>=(other) ⇒ Object
9
10
11
|
# File 'lib/box_packer/dimensions.rb', line 9
def >=(other)
zip_map(other, :>=).reduce(&:&)
end
|
#each_rotation {|Dimensions[x, y, z]| ... } ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/box_packer/dimensions.rb', line 13
def each_rotation
yield Dimensions[x, y, z]
yield Dimensions[x, z, y]
yield Dimensions[z, x, y]
yield Dimensions[z, y, x]
yield Dimensions[y, x, z]
yield Dimensions[y, z, x]
end
|
#to_s ⇒ Object
22
23
24
|
# File 'lib/box_packer/dimensions.rb', line 22
def to_s
to_a.join('x')
end
|
#volume ⇒ Object
5
6
7
|
# File 'lib/box_packer/dimensions.rb', line 5
def volume
@volume ||= to_a.reduce(&:*)
end
|