Class: CrystalScad::Hardware::Washer
- Inherits:
-
Hardware
- Object
- CrystalScadObject
- Primitive
- Assembly
- Hardware
- CrystalScad::Hardware::Washer
- Defined in:
- lib/crystalscad/Hardware.rb
Instance Attribute Summary
Attributes inherited from Assembly
#color, #hardware, #skip, #transformations, #x, #y, #z
Attributes inherited from Primitive
Attributes inherited from CrystalScadObject
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(size, args = {}) ⇒ Washer
constructor
A new instance of Washer.
- #show ⇒ Object
Methods inherited from Assembly
#*, #+, #-, #add_to_bom, #colorize, get_skip, get_views, #method_missing, #output, #part, #scad_output, #show_hardware, skip, #threads, #transform, view, #walk_tree
Methods inherited from Primitive
#mirror, #rotate, #rotate_around, #scale, #transform, #translate, #union
Methods inherited from CrystalScadObject
#save, #to_rubyscad, #walk_tree, #walk_tree_classes
Constructor Details
#initialize(size, args = {}) ⇒ Washer
Returns a new instance of Washer.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/crystalscad/Hardware.rb', line 172 def initialize(size,args={}) @args=args @size = size @args[:type] ||= "125" @args[:material] ||= "steel 8.8" @args[:surface] ||= "zinc plated" @chart_din125 = { 3.2 => {outer_diameter:7, height:0.5}, 3.7 => {outer_diameter:8, height:0.5}, 4.3 => {outer_diameter:9, height:0.8}, 5.3 => {outer_diameter:10, height:1.0}, 6.4 => {outer_diameter:12, height:1.6}, 8.4 => {outer_diameter:16, height:1.6}, 10.5 => {outer_diameter:20, height:2.0}, 13.0 => {outer_diameter:24, height:2.5}, } if @chart_din125[@size] == nil sizes = @chart_din125.map{|k,v| k}.sort.reverse.map{|s| s > @size ? size=s :nil} @size = size end @height = @chart_din125[@size][:height] @transformations ||= [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CrystalScad::Assembly
Instance Method Details
#description ⇒ Object
198 199 200 |
# File 'lib/crystalscad/Hardware.rb', line 198 def description "Washer #{@args[:size]}, Material #{@args[:material]} #{@args[:surface]}" end |
#show ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/crystalscad/Hardware.rb', line 202 def show add_to_bom washer = cylinder(d:@chart_din125[@size][:outer_diameter].to_f,h:@chart_din125[@size][:height].to_f) washer-= cylinder(d:@size,h:@chart_din125[@size][:outer_diameter].to_f+0.2).translate(z:-0.1) washer.color("Gainsboro") transform(washer) end |