debian-mirror-gitlab/lib/gitlab/cycle_analytics/summary/value.rb
2020-06-23 00:09:42 +05:30

54 lines
895 B
Ruby

# 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
def raw_value
0
end
def to_i
raw_value
end
def to_s
'-'
end
end
class Numeric < self
def initialize(value)
@value = value
end
def to_s
value.zero? ? '0' : value.to_s
end
def to_i
raw_value
end
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