Class: CrystalScad::Ruler

Inherits:
Assembly show all
Defined in:
lib/crystalscad/Ruler.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, #description, get_skip, get_views, #method_missing, #output, #scad_output, #show, #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(args = {}) ⇒ Ruler

Returns a new instance of Ruler.



20
21
22
23
24
25
26
27
28
# File 'lib/crystalscad/Ruler.rb', line 20

def initialize(args={})
	@x = args[:x] || 50
	@y = args[:y] || 5
	@height = args[:height] || 1
	@mm_mark = args[:mm_mark] || 3
	@five_mm_mark = args[:five_mm_mark] || 4
	@ten_mm_mark = args[:ten_mm_mark] || 5
	@rotation = args[:rotation] || 0
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CrystalScad::Assembly

Instance Method Details

#part(show) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/crystalscad/Ruler.rb', line 30

def part(show)
	res = cube([@x,@y,@height]).color("Gainsboro")
	(@x+1).times do |i|
		res += cube([0.1,@mm_mark,@height+0.1]).translate(x:i).color("black")
		if i % 10 == 0
			res += cube([0.1,@ten_mm_mark,@height+0.1]).translate(x:i).color("black")							
		elsif i % 5 == 0
			res += cube([0.1,@five_mm_mark,@height+0.1]).translate(x:i).color("black")							
		end
	end
	if @rotation > 0
		res = res.rotate(z:@rotation)
	end
	res
end