Class: CrystalScad::Cube

Inherits:
Primitive show all
Defined in:
lib/crystalscad/CrystalScad.rb

Instance Attribute Summary collapse

Attributes inherited from Primitive

#children

Attributes inherited from CrystalScadObject

#args, #transformations

Instance Method Summary collapse

Methods inherited from Primitive

#mirror, #rotate, #rotate_around, #scale, #transform, #translate, #union

Methods inherited from CrystalScadObject

#method_missing, #save, #walk_tree, #walk_tree_classes

Constructor Details

#initialize(*args) ⇒ Cube

Returns a new instance of Cube.



97
98
99
100
# File 'lib/crystalscad/CrystalScad.rb', line 97

def initialize(*args)
  super(args)
  @x,@y,@z = args[0][:size].map{|l| l.to_f}
end

Dynamic Method Handling

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

Instance Attribute Details

#xObject

Returns the value of attribute x.



95
96
97
# File 'lib/crystalscad/CrystalScad.rb', line 95

def x
  @x
end

#yObject

Returns the value of attribute y.



95
96
97
# File 'lib/crystalscad/CrystalScad.rb', line 95

def y
  @y
end

#zObject

Returns the value of attribute z.



95
96
97
# File 'lib/crystalscad/CrystalScad.rb', line 95

def z
  @z
end

Instance Method Details

#centerObject



122
123
124
125
# File 'lib/crystalscad/CrystalScad.rb', line 122

def center
	@transformations << Translate.new({x:-@x/2,y:-@y/2,z:-@z/2})
	self
end

#center_xObject



107
108
109
110
# File 'lib/crystalscad/CrystalScad.rb', line 107

def center_x
	@transformations << Translate.new({x:-@x/2})
	self
end

#center_xyObject



102
103
104
105
# File 'lib/crystalscad/CrystalScad.rb', line 102

def center_xy
	@transformations << Translate.new({x:-@x/2,y:-@y/2})
	self
end

#center_yObject



112
113
114
115
# File 'lib/crystalscad/CrystalScad.rb', line 112

def center_y
	@transformations << Translate.new({y:-@y/2})
	self
end

#center_zObject



117
118
119
120
# File 'lib/crystalscad/CrystalScad.rb', line 117

def center_z
	@transformations << Translate.new({z:-@z/2})
	self
end

#to_rubyscadObject



127
128
129
# File 'lib/crystalscad/CrystalScad.rb', line 127

def to_rubyscad
	return RubyScadBridge.new.cube(@args)		
end