Module: ChartFormat

Included in:
ChartBase
Defined in:
lib/jirametrics/chart_format.rb

Overview

Formats values for a Chart.js axis. Included by ChartBase and by the specs, which build the same strings to assert against.

Instance Method Summary collapse

Instance Method Details

#chart_format(object) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/jirametrics/chart_format.rb', line 6

def chart_format object
  # Not all ruby versions return the same string for to_s so we force to a known format.

  if object.is_a? Time
    object.strftime '%Y-%m-%dT%H:%M:%S%z' # => 2022-04-09T11:38:30-0700
  else
    object.to_s
  end
end