Class: CrystalScad::AdvancedPrimitive
- Inherits:
-
Primitive
- Object
- CrystalScadObject
- Primitive
- CrystalScad::AdvancedPrimitive
- Defined in:
- lib/crystalscad/CrystalScad.rb
Direct Known Subclasses
Constant Summary collapse
- NUMERIC_ATTRIBUTES =
[]
Instance Attribute Summary
Attributes inherited from Primitive
Attributes inherited from CrystalScadObject
Class Method Summary collapse
- .numeric_attributes(*attribute_names) ⇒ Object (also: numeric_attribute)
Instance Method Summary collapse
-
#initialize(attributes) ⇒ AdvancedPrimitive
constructor
A new instance of AdvancedPrimitive.
- #to_rubyscad ⇒ Object
Methods inherited from Primitive
#mirror, #rotate, #rotate_around, #scale, #transform, #translate, #union
Methods inherited from CrystalScadObject
#save, #walk_tree, #walk_tree_classes
Constructor Details
#initialize(attributes) ⇒ AdvancedPrimitive
Returns a new instance of AdvancedPrimitive.
271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/crystalscad/CrystalScad.rb', line 271 def initialize(attributes) @attr = attributes.collect { |k, v| value_output = if NUMERIC_ATTRIBUTES.include?(k.to_sym) v.to_f else "\"#{v}\"" end "#{k} = #{value_output}" }.join(', ') super end |
Class Method Details
.numeric_attributes(*attribute_names) ⇒ Object Also known as: numeric_attribute
261 262 263 264 265 |
# File 'lib/crystalscad/CrystalScad.rb', line 261 def self.numeric_attributes(*attribute_names) Array(attribute_names).flatten.each do |attrbute_name| NUMERIC_ATTRIBUTES << attrbute_name.to_sym end end |
Instance Method Details
#to_rubyscad ⇒ Object
284 285 286 |
# File 'lib/crystalscad/CrystalScad.rb', line 284 def to_rubyscad "#{@operation}(#{@attr});" end |