Sha256: f427607e10619d98e25b6d980247aa4fdaa1f314685424654626898e54f63df4

Contents?: true

Size: 762 Bytes

Versions: 9

Compression:

Stored size: 762 Bytes

Contents

module ReportsKit
  module Reports
    class Dimension
      attr_accessor :properties

      def initialize(properties)
        raise ArgumentError.new('Blank properties') if properties.blank?
        properties = { key: properties } if properties.is_a?(String)
        raise ArgumentError.new("Dimension properties must be a String or Hash, not a #{properties.class.name}: #{properties.inspect}") unless properties.is_a?(Hash)
        properties = properties.deep_symbolize_keys
        self.properties = properties
      end

      def key
        properties[:key]
      end

      def expression
        properties[:expression] || key
      end

      def label
        properties.key?(:label) ? properties[:label] : key.titleize
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
reports_kit-0.7.1 lib/reports_kit/reports/dimension.rb
reports_kit-0.7.0 lib/reports_kit/reports/dimension.rb
reports_kit-0.5.0 lib/reports_kit/reports/dimension.rb
reports_kit-0.4.1 lib/reports_kit/reports/dimension.rb
reports_kit-0.4.0 lib/reports_kit/reports/dimension.rb
reports_kit-0.3.3 lib/reports_kit/reports/dimension.rb
reports_kit-0.3.2 lib/reports_kit/reports/dimension.rb
reports_kit-0.3.1 lib/reports_kit/reports/dimension.rb
reports_kit-0.3.0 lib/reports_kit/reports/dimension.rb