Class: SolidRuby::Assemblies::Ruler
- Inherits:
-
Assembly
- Object
- SolidRubyObject
- Assembly
- SolidRuby::Assemblies::Ruler
- Defined in:
- lib/solidruby/assemblies/ruler.rb
Instance Attribute Summary
Attributes inherited from Assembly
#hardware, #skip, #transformations, #x, #y, #z
Attributes inherited from SolidRubyObject
#attributes, #children, #siblings, #transformations
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Ruler
constructor
A new instance of Ruler.
- #part(_show) ⇒ Object
Methods inherited from Assembly
#*, #+, #-, #add_to_bom, #color, #colorize, #description, get_skip, get_views, #output, #scad_output, #show, #show_hardware, skip, #threads, #transform, view, #walk_tree
Methods inherited from SolidRubyObject
#&, alias_attr, #debug, #debug?, #mirror, #place, #rotate, #rotate_around, #save, #scale, #to_rubyscad, #translate, #union, #walk_tree, #walk_tree_classes
Constructor Details
#initialize(args = {}) ⇒ Ruler
Returns a new instance of Ruler.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/solidruby/assemblies/ruler.rb', line 18 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 super(args) end |
Instance Method Details
#part(_show) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solidruby/assemblies/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 res = res.rotate(z: @rotation) if @rotation > 0 res end |