Sha256: d133bf93f61322bd042685ea8f0dcf2b21f993128c2254199c3f9d48a9caf12b

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbDashboardValue
    class StatValue < Playbook::PbKit::Base
      PROPS = %i[configured_classname
                 configured_data
                 configured_id
                 configured_unit
                 configured_value].freeze

      def initialize(classname: default_configuration,
                     data: default_configuration,
                     id: default_configuration,
                     unit: default_configuration,
                     value: default_configuration)

        self.configured_classname = classname
        self.configured_data = data
        self.configured_id = id
        self.configured_unit = unit
        self.configured_value = value
      end

      def value
        default_value(configured_value, 0)
      end

      def display_value
        pb_title = Playbook::PbTitle::Title.new(size: 1, text: value)
        ApplicationController.renderer.render(partial: pb_title, as: :object)
      end

      def unit
        default_value(configured_unit, nil)
      end

      def display_unit
        unless unit.nil?
          pb_unit = Playbook::PbTitle::Title.new(size: 3, text: unit)
          ApplicationController.renderer.render(partial: pb_unit, as: :object)
        end
      end

      def kit_class
        "pb_stat_value"
      end

      def to_partial_path
        "pb_dashboard_value/child_kits/stat_value"
      end

    private

      DEFAULT = Object.new
      private_constant :DEFAULT
      def default_configuration
        DEFAULT
      end
      attr_accessor(*PROPS)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-2.8.4 app/pb_kits/playbook/pb_dashboard_value/stat_value.rb
playbook_ui-2.8.3 app/pb_kits/playbook/pb_dashboard_value/stat_value.rb
playbook_ui-2.8.1 app/pb_kits/playbook/pb_dashboard_value/stat_value.rb