class SolidRuby::Assemblies::Ruler

Public Class Methods

new(args = {}) click to toggle source
Calls superclass method SolidRuby::Assemblies::Assembly::new
# 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

Public Instance Methods

part(_show) click to toggle source
# 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