Sha256: a7c8e9ac8bc8a5641e6b31de9b684b8a6d3c86ea53b78fc5728d755780bbc903

Contents?: true

Size: 678 Bytes

Versions: 30

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

module Gruff
  class Store
    # @private
    class BasicData < Struct.new(:label, :points, :color)
      def initialize(label, points, color)
        super(label.to_s, Array(points), color)
      end

      def empty?
        points.empty?
      end

      def columns
        points.length
      end

      def min
        points.compact.min
      end

      def max
        points.compact.max
      end

      def normalize(minimum:, spread:)
        norm_points = points.map do |point|
          point.nil? ? nil : (point.to_f - minimum.to_f) / spread
        end

        self.class.new(label, norm_points, color)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gruff-0.24.0-java lib/gruff/store/basic_data.rb
gruff-0.24.0 lib/gruff/store/basic_data.rb
gruff-0.23.0 lib/gruff/store/basic_data.rb
gruff-0.23.0-java lib/gruff/store/basic_data.rb
gruff-0.22.0 lib/gruff/store/basic_data.rb
gruff-0.22.0-java lib/gruff/store/basic_data.rb
gruff-0.21.0-java lib/gruff/store/basic_data.rb
gruff-0.21.0 lib/gruff/store/basic_data.rb
gruff-0.20.0-java lib/gruff/store/basic_data.rb
gruff-0.20.0 lib/gruff/store/basic_data.rb
gruff-0.19.0 lib/gruff/store/basic_data.rb
gruff-0.19.0-java lib/gruff/store/basic_data.rb
gruff-0.18.0-java lib/gruff/store/basic_data.rb
gruff-0.18.0 lib/gruff/store/basic_data.rb
gruff-0.17.0-java lib/gruff/store/basic_data.rb
gruff-0.17.0 lib/gruff/store/basic_data.rb
gruff-0.16.0 lib/gruff/store/basic_data.rb
gruff-0.16.0-java lib/gruff/store/basic_data.rb
gruff-0.15.0-java lib/gruff/store/basic_data.rb
gruff-0.15.0 lib/gruff/store/basic_data.rb