Class: Nazar::CellFormatter

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

Instance Method Summary collapse

Constructor Details

#initialize(value, type: :string) ⇒ CellFormatter

Returns a new instance of CellFormatter.



5
6
7
8
# File 'lib/nazar/cell_formatter.rb', line 5

def initialize(value, type: :string)
  @value = value
  @type = type
end

Instance Method Details

#formatObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/nazar/cell_formatter.rb', line 10

def format
  case type
  when :boolean
    format_boolean
  when :integer
    format_number
  else
    value.nil? ? format_nil : inteligent_format
  end
end