lib/physical/cuboid.rb in physical-0.4.8 vs lib/physical/cuboid.rb in physical-0.4.9

- old
+ new

@@ -2,10 +2,12 @@ require 'measured' module Physical class Cuboid + include PropertyReaders + attr_reader :dimensions, :length, :width, :height, :weight, :id, :properties def initialize(id: nil, dimensions: [], weight: Measured::Weight(0, :g), properties: {}) @id = id || SecureRandom.uuid @weight = Types::Weight[weight] @@ -30,30 +32,9 @@ other.is_a?(self.class) && id == other&.id end private - - NORMALIZED_METHOD_REGEX = /(\w+)\??$/.freeze - - def method_missing(method) - symbolized_properties = properties.symbolize_keys - method_name = normalize_method_name(method) - if symbolized_properties.key?(method_name) - symbolized_properties[method_name] - else - super - end - end - - def respond_to_missing?(method, *args) - method_name = normalize_method_name(method) - properties.symbolize_keys.key?(method_name) || super - end - - def normalize_method_name(method) - method.to_s.sub(NORMALIZED_METHOD_REGEX, '\1').to_sym - end def fill_dimensions(dimensions) dimensions.fill(dimensions.length..2) do |index| @dimensions[index] || Measured::Length(self.class::DEFAULT_LENGTH, :cm) end