Class: Formatting::CellFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/formatting.rb

Overview

CellFormatter class format data in cell

Class Method Summary collapse

Class Method Details

.format_value(value, opts) ⇒ String

Returns Formatted string value.

Parameters:

  • String (String)

    value for formatting

  • opts (Hash)

    options: format, max width, alignment

Returns:

  • (String)

    Formatted string value



31
32
33
34
35
36
37
38
# File 'lib/formatting.rb', line 31

def self.format_value(value,opts)
  if opts.has_key?(:format)
    cell = sprintf(opts[:format],value)
  else
    cell = sprintf("%#{opts[:max_width]}s",value)
  end
  Formatting.format_value_by_width_and_just(cell,opts[:max_width],opts[:just])
end