summaryrefslogtreecommitdiff
path: root/lib/gitlab/cycle_analytics/summary/value.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/cycle_analytics/summary/value.rb')
-rw-r--r--lib/gitlab/cycle_analytics/summary/value.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/gitlab/cycle_analytics/summary/value.rb b/lib/gitlab/cycle_analytics/summary/value.rb
new file mode 100644
index 00000000000..ce32132e048
--- /dev/null
+++ b/lib/gitlab/cycle_analytics/summary/value.rb
@@ -0,0 +1,42 @@
+# 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 to_s
+ '-'
+ end
+ end
+
+ class Numeric < self
+ def initialize(value)
+ @value = value
+ end
+
+ def to_s
+ value.zero? ? '0' : value.to_s
+ 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