Sha256: 2f1b973554e0e40c1e46ee032d91bb2d95f8ce696f7eead85072befad94e31da

Contents?: true

Size: 838 Bytes

Versions: 5

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

module Thinreports
  module BasicReport
    module Core
      module Shape
        module TextBlock
          module Formatter
            class Basic
              include Utils

              attr_reader :format

              def initialize(format)
                @format = format
              end

              def apply(value)
                value = apply_format_to(value) if applicable?(value)

                return value if blank_value?(format.format_base)

                format.format_base.gsub(/\{value\}/, value.to_s)
              end

              private

              def apply_format_to(value)
                value
              end

              def applicable?(_value)
                true
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.14.2 lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb
thinreports-0.14.1 lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb
thinreports-0.14.0 lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb
thinreports-0.13.1 lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb
thinreports-0.13.0 lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb