Class: CrystalScad::Hardware::Washer

Inherits:
Hardware show all
Defined in:
lib/crystalscad/Hardware.rb

Instance Attribute Summary

Attributes inherited from Assembly

#color, #hardware, #skip, #transformations, #x, #y, #z

Attributes inherited from Primitive

#children

Attributes inherited from CrystalScadObject

#args, #transformations

Instance Method Summary collapse

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

#method_missing, #save, #to_rubyscad, #walk_tree, #walk_tree_classes

Constructor Details

#initialize(size, args = {}) ⇒ Washer

Returns a new instance of Washer.



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/crystalscad/Hardware.rb', line 171

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

#descriptionObject



197
198
199
# File 'lib/crystalscad/Hardware.rb', line 197

def description
	"Washer #{@args[:size]}, Material #{@args[:material]} #{@args[:surface]}"
end

#showObject



201
202
203
204
205
206
207
# File 'lib/crystalscad/Hardware.rb', line 201

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