Class: Coalla::TextFormatter
- Inherits:
-
Object
- Object
- Coalla::TextFormatter
- Defined in:
- lib/coalla/builders/text_formatter.rb
Instance Method Summary collapse
- #format(method) ⇒ Object
-
#initialize(object) ⇒ TextFormatter
constructor
A new instance of TextFormatter.
Constructor Details
#initialize(object) ⇒ TextFormatter
Returns a new instance of TextFormatter.
3 4 5 6 7 |
# File 'lib/coalla/builders/text_formatter.rb', line 3 def initialize(object) @object = object # TODO (vl): refactor this @columns = @object.class.columns.index_by(&:name).with_indifferent_access end |
Instance Method Details
#format(method) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/coalla/builders/text_formatter.rb', line 9 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 |