class SolidRuby::CSGModifiers::CSGModifier
Public Class Methods
new(object, attributes)
click to toggle source
Calls superclass method
SolidRuby::SolidRubyObject::new
# File lib/solidruby/csg_modifiers/csg_modifier.rb, line 18 def initialize(object, attributes) super(attributes) @transformations = [] @children = [object] @attributes = attributes end
Public Instance Methods
to_rubyscad()
click to toggle source
# File lib/solidruby/csg_modifiers/csg_modifier.rb, line 25 def to_rubyscad att = @attributes if att.is_a? Hash att = @attributes.select {|k, v| !v.nil? }.collect do |k, v| sv = RubyScadBridge.new.format_value(v) "#{k} = #{sv}" end.sort_by{ |x| x[0] == 'f' ? ('z' + x) : x } end att = att.join(', ') if att.is_a? Array # Apparently this doesn't work for CSGModifiers, like it does for other things in RubyScad? # also this is a dirty, dirty hack. att = att.gsub('fn', '$fn').gsub('$$', '$') ret = "#{@operation}(#{att}){" @children ||= [] @children.each do |child| begin ret += child.walk_tree rescue NoMethodError end end ret += '}' end