Class: Boxbot::Dimensions
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Boxbot::Dimensions
- Defined in:
- lib/boxbot/dimensions.rb
Overview
Holds the internal dimensions of the box, including laser-specific parameters such as kerf and material thickness.
Instance Attribute Summary collapse
-
#depth ⇒ Float
The current value of depth.
-
#height ⇒ Float
The current value of height.
-
#kerf ⇒ Float
The current value of kerf.
-
#tab ⇒ Float
desired tab width/length used as a guide.
-
#thickness ⇒ Float
The current value of thickness.
-
#width ⇒ Float
The current value of width.
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Dimensions
constructor
A new instance of Dimensions.
-
#inner_box ⇒ Array<Integer>
Returns dimensions of the inner box.
-
#outer_box ⇒ Array<Integer>
Returns dimensions of the outer box by adding thickness to the inner box.
-
#outer_box_with_kerf ⇒ Array<Integer>
Returns dimensions of the outer box with kerf added.
-
#tab_width ⇒ Float
Returns either provided or the default tab width.
Constructor Details
#initialize(*args, &block) ⇒ Dimensions
33 34 35 36 |
# File 'lib/boxbot/dimensions.rb', line 33 def initialize(*args, &block) super(*args, &block) self.kerf ||= 0 end |
Instance Attribute Details
#depth ⇒ Float
23 24 25 |
# File 'lib/boxbot/dimensions.rb', line 23 def depth @depth end |
#height ⇒ Float
23 24 25 |
# File 'lib/boxbot/dimensions.rb', line 23 def height @height end |
#kerf ⇒ Float
23 24 25 |
# File 'lib/boxbot/dimensions.rb', line 23 def kerf @kerf end |
#tab ⇒ Float
desired tab width/length used as a guide
23 24 25 |
# File 'lib/boxbot/dimensions.rb', line 23 def tab @tab end |
#thickness ⇒ Float
23 24 25 |
# File 'lib/boxbot/dimensions.rb', line 23 def thickness @thickness end |
#width ⇒ Float
23 24 25 |
# File 'lib/boxbot/dimensions.rb', line 23 def width @width end |
Instance Method Details
#inner_box ⇒ Array<Integer>
Returns dimensions of the inner box.
40 41 42 |
# File 'lib/boxbot/dimensions.rb', line 40 def inner_box [width, height, depth] end |
#outer_box ⇒ Array<Integer>
Returns dimensions of the outer box by adding thickness to the inner box.
46 47 48 |
# File 'lib/boxbot/dimensions.rb', line 46 def outer_box inner_box.map { |d| o(d) } end |
#outer_box_with_kerf ⇒ Array<Integer>
Returns dimensions of the outer box with kerf added.
52 53 54 |
# File 'lib/boxbot/dimensions.rb', line 52 def outer_box_with_kerf inner_box.map { |d| o(d, add_kerf: true) } end |
#tab_width ⇒ Float
Returns either provided or the default tab width. The default is computed as ‘4 x thickness.`
59 60 61 62 |
# File 'lib/boxbot/dimensions.rb', line 59 def tab_width raise ArgumentError, 'Thickness is zero?' if thickness.zero? tab ? tab : thickness * 4 end |