Sha256: 2f6c4631ace65b988f40e9787e08a30e38061ab343bf5b11795f5287c495398a

Contents?: true

Size: 885 Bytes

Versions: 8

Compression:

Stored size: 885 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
        # recalculate anything.
        #
        def recalculate float
          float
        end

        #
        #
        def ids float_as_sym
          @bundle.ids recalculate(float_as_sym.to_s.to_f).to_s.to_sym
        end

        #
        #
        def weight float_as_sym
          @bundle.weight recalculate(float_as_sym.to_s.to_f).to_s.to_sym
        end

      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
picky-3.4.3 lib/picky/wrappers/bundle/calculation.rb
picky-3.4.2 lib/picky/wrappers/bundle/calculation.rb
picky-3.4.1 lib/picky/wrappers/bundle/calculation.rb
picky-3.4.0 lib/picky/wrappers/bundle/calculation.rb
picky-3.3.3 lib/picky/wrappers/bundle/calculation.rb
picky-3.3.2 lib/picky/wrappers/bundle/calculation.rb
picky-3.3.1 lib/picky/wrappers/bundle/calculation.rb
picky-3.3.0 lib/picky/wrappers/bundle/calculation.rb