To be honest you do not need class variables for this and you should
not do the calculation in the initialize method as you do not know
what value to use for kerf. This is a better solution.
class Machine
def initialize(part_width, part_length)
@part_width = part_width
@part_length = part_length
end
def laser
puts calc(20)
end
def turret
puts calc(10)
end
private
def calc(kerf)
sheet_width = 60
sheet_length = 120
parts_y = sheet_width / (@part_width + kerf)
parts_x = sheet_length / (@part_length + kerf)
return parts_y * parts_x
end
end
machine1 = Machine.new(10 , 20)
machine1.laser
machine1.turret