Sha256: 3f8d5c810192e46868454313907ae3191fc9fcd94952a9ce70b64bc8f12d0840

Contents?: true

Size: 320 Bytes

Versions: 9

Compression:

Stored size: 320 Bytes

Contents

# frozen_string_literal: true

class MathCaster < Sinclair::Caster
  cast_with(:float, :to_f)

  cast_with(:log) do |value, base: 10|
    value = MathCaster.cast(value, :float)

    Math.log(value, base)
  end

  cast_with(:exp) do |value, base: 10|
    value = MathCaster.cast(value, :float)

    base**value
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/support/models/math_caster.rb
sinclair-2.1.0 spec/support/models/math_caster.rb
sinclair-2.0.1 spec/support/models/math_caster.rb
sinclair-2.0.0 spec/support/models/math_caster.rb
sinclair-1.16.3 spec/support/models/math_caster.rb
sinclair-1.16.2 spec/support/models/math_caster.rb
sinclair-1.16.1 spec/support/models/math_caster.rb
sinclair-1.16.0 spec/support/models/math_caster.rb
sinclair-1.15.0 spec/support/models/math_caster.rb