Sha256: 7ef7b2522a12f3c85ef6c4b68bf29f017db3bbfea74a2c94d9f0da42fc8cb889

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 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

2 entries across 2 versions & 1 rubygems

Version Path
thinreports-0.8.1 lib/thinreports/core/shape/text_block/formatter/basic.rb
thinreports-0.8.0 lib/thinreports/core/shape/text_block/formatter/basic.rb