Sha256: d869f925141b24a4c2ea6a8dacbcd4777f868bb7a38da539bf8945b9549354f9

Contents?: true

Size: 647 Bytes

Versions: 4

Compression:

Stored size: 647 Bytes

Contents

# coding: utf-8

module ThinReports
  module Core::Shape::TextBlock
    
    # @private
    class Formatter::Basic
      attr_reader :format
      
      def initialize(format)
        @format = format
      end
      
      def apply(value)
        if applicable?(value)
          value = apply_format_to(value)
        end
        
        unless format.format_base.blank?
          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

4 entries across 4 versions & 1 rubygems

Version Path
thinreports-0.7.7 lib/thinreports/core/shape/text_block/formatter/basic.rb
thinreports-0.7.6 lib/thinreports/core/shape/text_block/formatter/basic.rb
thinreports-0.7.5 lib/thinreports/core/shape/text_block/formatter/basic.rb
thinreports-0.7.0 lib/thinreports/core/shape/text_block/formatter/basic.rb