Sha256: 6ebdd644f32a88e89f038175b0fa0566c0655d857ba0b071e948ccc2fe1c9fdc

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

module Coalla
  class TextFormatter
    def initialize(object)
      @object = object
      # TODO (vl): refactor this
      @columns = @object.class.columns.index_by(&:name).with_indifferent_access
    end

    def format(method)
      method_value = @object.send(method)
      return unless method_value

      method_type = @columns[method].try(:type)
      if method_type == :datetime
        method_value = method_value.localtime if method_value.respond_to?(:localtime)
        Russian.strftime(method_value, '%d.%m.%Y %H:%M')
      else
        method_value
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coalla-cms-0.7.0.0 lib/coalla/builders/text_formatter.rb
coalla-cms-0.6.1.1 lib/coalla/builders/text_formatter.rb
coalla-cms-0.6.0.9 lib/coalla/builders/text_formatter.rb