Sha256: 0d98f8fbd3a06b17c50dcc249d197e2886171646935cd01709fd961d7ebafb43

Contents?: true

Size: 653 Bytes

Versions: 17

Compression:

Stored size: 653 Bytes

Contents

module Xsys
  module Model
    class ProductPackage
      def self.attr_list
        [:length, :width, :height, :weight, :ean, :name]
      end

      attr_reader *attr_list

      def initialize(attributes={})
        attributes.each do |k, v|
          decimal_fields = ['length', 'width', 'height', 'weight']

          if decimal_fields.include?(k.to_s)
            self.send("#{k}=", BigDecimal.new(v)) unless v.nil?
          else
            self.send("#{k}=", v) if self.respond_to?(k)
          end
        end
      end

      def volume
        length * width * height
      end

      private

      attr_writer *attr_list
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
xsys-0.47.0 lib/xsys/model/product_package.rb
xsys-0.46.0 lib/xsys/model/product_package.rb
xsys-0.45.0 lib/xsys/model/product_package.rb
xsys-0.44.0 lib/xsys/model/product_package.rb
xsys-0.43.0 lib/xsys/model/product_package.rb
xsys-0.42.0 lib/xsys/model/product_package.rb
xsys-0.41.0 lib/xsys/model/product_package.rb
xsys-0.40.0 lib/xsys/model/product_package.rb
xsys-0.39.0 lib/xsys/model/product_package.rb
xsys-0.38.0 lib/xsys/model/product_package.rb
xsys-0.37.0 lib/xsys/model/product_package.rb
xsys-0.36.0 lib/xsys/model/product_package.rb
xsys-0.35.0 lib/xsys/model/product_package.rb
xsys-0.34.0 lib/xsys/model/product_package.rb
xsys-0.33.0 lib/xsys/model/product_package.rb
xsys-0.32.0 lib/xsys/model/product_package.rb
xsys-0.31.0 lib/xsys/model/product_package.rb