Sha256: cd372b16e4d0ae2da09e29824386284810faac6e2c2dbedcbf3f83366858bc0c

Contents?: true

Size: 887 Bytes

Versions: 17

Compression:

Stored size: 887 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. Use a block here?
        #
        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

17 entries across 17 versions & 1 rubygems

Version Path
picky-4.0.0pre1 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.16 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.15 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.14 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.13 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.12 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.11 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.10 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.9 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.8 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.7 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.6 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.4 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.3 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.2 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.1 lib/picky/wrappers/bundle/calculation.rb
picky-3.6.0 lib/picky/wrappers/bundle/calculation.rb