Sha256: 6eba41dff09cba9a9a4b4a7e9ffe2a86f03790c3e840913091868212070ffcfd

Contents?: true

Size: 595 Bytes

Versions: 4

Compression:

Stored size: 595 Bytes

Contents

module Danica
  class Function::Spatial < Function
    variables :time, :acceleration, :initial_space, :initial_velocity
    delegate :to_f, :to_tex, :to_gnu, to: :sum

    private

    def sum
      @sum ||= Sum.new(parcels)
    end

    def parcels
      [
        initial_space,
        spatial_velocity,
        spatial_acceleration
      ]
    end

    def spatial_velocity
      Product.new(initial_velocity, time)
    end

    def spatial_acceleration
      Division.new(Product.new(acceleration, time_squared), 2)
    end

    def time_squared
      Power.new(time, 2)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danica-2.1.0 spec/support/models/functions/spatial.rb
danica-2.0.6 spec/support/models/functions/spatial.rb
danica-2.0.5 spec/support/models/functions/spatial.rb
danica-2.0.4 spec/support/models/functions/spatial.rb