Sha256: d4b41c4eb3a58d75a99fc33a5e307079b483826a4ccbf6a9936fc6f91dfe7a4c

Contents?: true

Size: 618 Bytes

Versions: 3

Compression:

Stored size: 618 Bytes

Contents

# coding: utf-8

module Thinreports
  module Core::Shape::TextBlock

    class Formatter::Basic
      include Utils

      attr_reader :format

      def initialize(format)
        @format = format
      end

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

        unless blank_value?(format.format_base)
          format.format_base.gsub(/\{value\}/, value.to_s)
        else
          value
        end
      end

    private

      def apply_format_to(value)
        value
      end

      def applicable?(_value)
        true
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.9.1 lib/thinreports/core/shape/text_block/formatter/basic.rb
thinreports-0.9.0 lib/thinreports/core/shape/text_block/formatter/basic.rb
thinreports-0.8.2 lib/thinreports/core/shape/text_block/formatter/basic.rb