Sha256: 854da4706ec32c87789efc047c293dda2844d1ce7f4c6371962116ac5c483296

Contents?: true

Size: 641 Bytes

Versions: 5

Compression:

Stored size: 641 Bytes

Contents

# frozen_string_literal: true

require 'measured'

module Physical
  class Box < Cuboid
    DEFAULT_LENGTH = BigDecimal::INFINITY
    attr_reader :inner_dimensions,
                :inner_length,
                :inner_width,
                :inner_height

    def initialize(inner_dimensions: [], **args)
      super args
      @inner_dimensions = fill_dimensions(Types::Dimensions[inner_dimensions])
      @inner_length, @inner_width, @inner_height = *@inner_dimensions
    end

    def inner_volume
      Measured::Volume(
        inner_dimensions.map { |d| d.convert_to(:cm).value }.reduce(1, &:*),
        :ml
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
physical-0.4.0 lib/physical/box.rb
physical-0.3.3 lib/physical/box.rb
physical-0.3.2 lib/physical/box.rb
physical-0.3.1 lib/physical/box.rb
physical-0.3.0 lib/physical/box.rb