Sha256: 48b263b1ebc64352edc2a8508df162c8c3942de70ab337070fe99b5f8cb9c559

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 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_kit"
      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

2 entries across 2 versions & 1 rubygems

Version Path
playbook_ui-2.8.6 app/pb_kits/playbook/pb_dashboard_value/stat_value.rb
playbook_ui-2.8.5 app/pb_kits/playbook/pb_dashboard_value/stat_value.rb