Sha256: 877e830f97212643d78d86ea0b337566cac70bbd775b781cb828a7cd497f8784

Contents?: true

Size: 519 Bytes

Versions: 20

Compression:

Stored size: 519 Bytes

Contents

# frozen_string_literal: true

module Spout
  module Models
    # Defines a continuous or discrete bucket for tables and graphs
    class Bucket
      attr_accessor :start, :stop

      def initialize(start, stop, discrete: false)
        @start = start
        @stop = stop
        @discrete = discrete
      end

      def in_bucket?(value)
        value >= @start && value <= @stop
      end

      def display_name
        return "#{@start}" if @discrete
        "#{@start} to #{@stop}"
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
spout-1.0.0 lib/spout/models/bucket.rb
spout-1.0.0.beta3 lib/spout/models/bucket.rb
spout-1.0.0.beta2 lib/spout/models/bucket.rb
spout-1.0.0.beta1 lib/spout/models/bucket.rb
spout-0.14.1 lib/spout/models/bucket.rb
spout-0.14.0 lib/spout/models/bucket.rb
spout-0.14.0.rc lib/spout/models/bucket.rb
spout-0.14.0.beta3 lib/spout/models/bucket.rb
spout-0.14.0.beta2 lib/spout/models/bucket.rb
spout-0.14.0.beta1 lib/spout/models/bucket.rb
spout-0.13.0 lib/spout/models/bucket.rb
spout-0.13.0.beta2 lib/spout/models/bucket.rb
spout-0.13.0.beta1 lib/spout/models/bucket.rb
spout-0.12.1 lib/spout/models/bucket.rb
spout-0.12.0 lib/spout/models/bucket.rb
spout-0.12.0.rc2 lib/spout/models/bucket.rb
spout-0.12.0.rc lib/spout/models/bucket.rb
spout-0.12.0.beta2 lib/spout/models/bucket.rb
spout-0.12.0.beta1 lib/spout/models/bucket.rb
spout-0.11.1 lib/spout/models/bucket.rb