Sha256: 60c0e591b4d10f62886d4aedb08eeb6a81b00870eae682a447797048c2202efc

Contents?: true

Size: 848 Bytes

Versions: 21

Compression:

Stored size: 848 Bytes

Contents

module Picky

  module Generators

    module Weights

      # Uses a constant weight.
      # Default is 0.0.
      #
      # Note: This is not saved.
      #
      # Examples:
      #   * Picky::Weights::Constant.new       # Uses 0.0 as a constant weight.
      #   * Picky::Weights::Constant.new(3.14) # Uses 3.14 as a constant weight.
      #
      class Constant < Runtime

        def initialize weight = 0.0
          @weight = weight
        end

        # Always returns the constant weight,
        # except if there are no ids.
        #
        def [] _

          @weight
        end

        # Returns the constant weight,
        # except if there are no ids.
        #
        # Not really used, but is more
        # correct this way.
        #
        def weight_for _
          @weight
        end

      end

    end

  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
picky-4.0.0pre1 lib/picky/generators/weights/constant.rb
picky-3.6.16 lib/picky/generators/weights/constant.rb
picky-3.6.15 lib/picky/generators/weights/constant.rb
picky-3.6.14 lib/picky/generators/weights/constant.rb
picky-3.6.13 lib/picky/generators/weights/constant.rb
picky-3.6.12 lib/picky/generators/weights/constant.rb
picky-3.6.11 lib/picky/generators/weights/constant.rb
picky-3.6.10 lib/picky/generators/weights/constant.rb
picky-3.6.9 lib/picky/generators/weights/constant.rb
picky-3.6.8 lib/picky/generators/weights/constant.rb
picky-3.6.7 lib/picky/generators/weights/constant.rb
picky-3.6.6 lib/picky/generators/weights/constant.rb
picky-3.6.4 lib/picky/generators/weights/constant.rb
picky-3.6.3 lib/picky/generators/weights/constant.rb
picky-3.6.2 lib/picky/generators/weights/constant.rb
picky-3.6.1 lib/picky/generators/weights/constant.rb
picky-3.6.0 lib/picky/generators/weights/constant.rb
picky-3.5.4 lib/picky/generators/weights/constant.rb
picky-3.5.3 lib/picky/generators/weights/constant.rb
picky-3.5.2 lib/picky/generators/weights/constant.rb