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-3.5.1 lib/picky/generators/weights/constant.rb