Sha256: c82675eb797bb0d021d228b87c019fa7ddba4670679ce0625bc0e9bc388343bf

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Cells
      # Formats the value as a money value
      #
      # The value is expected to be in cents.
      # Adds a class to the cell to allow for custom styling
      class CurrencyComponent < CellComponent
        def initialize(options:, **)
          super(**)

          @options = options
        end

        def rendered_value
          value.present? ? number_to_currency(value / 100.0, @options) : ""
        end

        private

        def default_html_attributes
          { class: "type-currency" }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katalyst-tables-3.3.1 app/components/katalyst/tables/cells/currency_component.rb
katalyst-tables-3.3.0 app/components/katalyst/tables/cells/currency_component.rb
katalyst-tables-3.2.0 app/components/katalyst/tables/cells/currency_component.rb
katalyst-tables-3.1.0 app/components/katalyst/tables/cells/currency_component.rb