class SolidRuby::BillOfMaterial::BillOfMaterial
Attributes
parts[RW]
Public Class Methods
new()
click to toggle source
# File lib/solidruby/bill_of_material.rb, line 19 def initialize @parts = {} end
Public Instance Methods
add(part, quantity = 1)
click to toggle source
# File lib/solidruby/bill_of_material.rb, line 23 def add(part, quantity = 1) @parts[part] ||= 0 @parts[part] += quantity end
output()
click to toggle source
# File lib/solidruby/bill_of_material.rb, line 28 def output @parts.map { |key, qty| "#{qty} x #{key}" }.join("\n") end
save(filename = 'output/bom.txt')
click to toggle source
# File lib/solidruby/bill_of_material.rb, line 32 def save(filename = 'output/bom.txt') file = File.open(filename, 'w') file.puts output file.close end