class Boxbot::Dimensions

Holds the internal dimensions of the box, including laser-specific parameters such as kerf and material thickness.

@author Konstantin Gredeskoul

@attr [Float] width @attr [Float] height @attr [Float] depth @attr [Float] kerf @attr [Float] thickness @attr [Float] tab desired tab width/length used as a guide

@example compute number of tabs for the vertical dimension

dim = Boxbot::Dimension.new(width: 10, height: 2, depth: 3, ...)
dim.inner_box # => [ 10, 2, 3 ]

Public Class Methods

new(*args, &block) click to toggle source
Calls superclass method
# File lib/boxbot/dimensions.rb, line 33
def initialize(*args, &block)
  super(*args, &block)
  self.kerf ||= 0
end

Public Instance Methods

inner_box() click to toggle source

Returns dimensions of the inner box. @return [Array<Integer>] three dimensional array of width, height, depth

# File lib/boxbot/dimensions.rb, line 40
def inner_box
  [width, height, depth]
end
outer_box() click to toggle source

Returns dimensions of the outer box by adding thickness to the inner box. @return [Array<Integer>] three dimensional array of width, height, depth

# File lib/boxbot/dimensions.rb, line 46
def outer_box
  inner_box.map { |d| o(d) }
end
outer_box_with_kerf() click to toggle source

Returns dimensions of the outer box with kerf added. @return [Array<Integer>] three dimensional array of width, height, depth

# File lib/boxbot/dimensions.rb, line 52
def outer_box_with_kerf
  inner_box.map { |d| o(d, add_kerf: true) }
end
tab_width() click to toggle source

Returns either provided or the default tab width. The default is computed as `4 x thickness.` @return [Float] tab width

# File lib/boxbot/dimensions.rb, line 59
def tab_width
  raise ArgumentError, 'Thickness is zero?' if thickness.zero?
  tab ? tab : thickness * 4
end

Private Instance Methods

o(attr, add_kerf: false) click to toggle source
# File lib/boxbot/dimensions.rb, line 66
def o(attr, add_kerf: false)
  attr + 2 * thickness + (add_kerf ? 2 * kerf : 0)
end