Sha256: caa7b22b1b6edb43b0de90c67a090f73025e177c56bf2a5ed8fd1ee5d26e1399

Contents?: true

Size: 869 Bytes

Versions: 5

Compression:

Stored size: 869 Bytes

Contents

module Picky

  module Wrappers

    module Bundle

      # A calculation rewrites the symbol into a float.
      #
      # Note: A calculation will try to find a float in the index,
      #       not a sym.
      #
      # TODO I really need to allow integers as keys.
      #      The code below is just not up to the needed quality.
      #      Use key_format :to_i?
      #
      class Calculation < Wrapper

        # API.
        #
        # By default, a calculation does not
        # calculate anything.
        #
        def calculate float
          float
        end

        # TODO Symbols.
        #
        def ids float_str
          @bundle.ids calculate(float_str.to_f).to_s
        end

        # TODO Symbols.
        #
        def weight float_str
          @bundle.weight calculate(float_str.to_f).to_s
        end

      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
picky-3.5.4 lib/picky/wrappers/bundle/calculation.rb
picky-3.5.3 lib/picky/wrappers/bundle/calculation.rb
picky-3.5.2 lib/picky/wrappers/bundle/calculation.rb
picky-3.5.1 lib/picky/wrappers/bundle/calculation.rb
picky-3.5.0 lib/picky/wrappers/bundle/calculation.rb