Class: SolidRuby::Transformations::Translate

Inherits:
Transformation show all
Defined in:
lib/solidruby/transformations/translate.rb

Instance Attribute Summary collapse

Attributes inherited from Transformation

#args

Instance Method Summary collapse

Methods inherited from Transformation

#walk_tree

Constructor Details

#initialize(args = {}) ⇒ Translate

Returns a new instance of Translate.



20
21
22
23
24
25
# File 'lib/solidruby/transformations/translate.rb', line 20

def initialize(args={})
  super(args)
  @x = args[:x] || 0
  @y = args[:y] || 0
  @z = args[:z] || 0
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



18
19
20
# File 'lib/solidruby/transformations/translate.rb', line 18

def x
  @x
end

#yObject

Returns the value of attribute y.



18
19
20
# File 'lib/solidruby/transformations/translate.rb', line 18

def y
  @y
end

#zObject

Returns the value of attribute z.



18
19
20
# File 'lib/solidruby/transformations/translate.rb', line 18

def z
  @z
end

Instance Method Details

#to_rubyscadObject



27
28
29
30
31
# File 'lib/solidruby/transformations/translate.rb', line 27

def to_rubyscad
  #ignore empty transformations
  return '' if @x == 0 && @y == 0 && @z == 0
  RubyScadBridge.new.translate({x: @x, y: @y, z: @z}).delete('"')
end