2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module CycleAnalytics
|
|
|
|
module Summary
|
|
|
|
class Value
|
|
|
|
attr_reader :value
|
|
|
|
|
|
|
|
def raw_value
|
|
|
|
value
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
class None < self
|
2020-06-23 00:09:42 +05:30
|
|
|
def raw_value
|
|
|
|
0
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_i
|
|
|
|
raw_value
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
def to_s
|
|
|
|
'-'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Numeric < self
|
|
|
|
def initialize(value)
|
|
|
|
@value = value
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
2020-10-24 23:57:45 +05:30
|
|
|
value == 0 ? '0' : value.to_s
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
def to_i
|
|
|
|
raw_value
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
class PrettyNumeric < Numeric
|
|
|
|
def to_s
|
|
|
|
# 0 is shown as -
|
|
|
|
(value || 0).nonzero? ? super : None.new.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|