Class: GitlabInternalEventsCli::Helpers::MetricOptions::Option
- Inherits:
-
Struct
- Object
- Struct
- GitlabInternalEventsCli::Helpers::MetricOptions::Option
- Includes:
- Formatting
- Defined in:
- lib/gitlab_internal_events_cli/helpers/metric_options.rb
Overview
Formats & structures a single select/multiselect menu item
Constant Summary
Constants included from Formatting
Formatting::DEFAULT_WINDOW_HEIGHT, Formatting::DEFAULT_WINDOW_WIDTH
Instance Method Summary collapse
-
#disabled ⇒ Object
Returns the string to include at the end of disabled menu items.
-
#filter_phrase ⇒ Object
ex) “where label/property is…”.
-
#formatted ⇒ Hash
ex) Monthly/Weekly count of unique users who triggered cli_template_included where label/property is…
-
#highlighted_phrase ⇒ Object
ex) “unique users”.
- #identifier ⇒ Object
-
#operator_phrase ⇒ Object
ex) “count of unique users who triggered cli_template_included”.
-
#time_frame_phrase ⇒ Object
ex) “Monthly/Weekly”.
Methods included from Formatting
#clear_format, #counter, #divider, #format_error, #format_heading, #format_help, #format_info, #format_prefix, #format_prompt, #format_selection, #format_subheader, #format_warning, #progress_bar
Instance Method Details
#disabled ⇒ Object
Returns the string to include at the end of disabled menu items. Nil if menu item shouldn’t be disabled
243 244 245 246 247 248 249 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 243 def disabled if defined pastel.bold(format_help('(already defined)')) elsif !supported pastel.bold(format_help("(#{identifier.value} unavailable)")) end end |
#filter_phrase ⇒ Object
ex) “where label/property is…”
234 235 236 237 238 239 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 234 def filter_phrase return unless filter_name return 'where filtered' if disabled "#{format_info("where #{filter_name}")} is..." end |
#formatted ⇒ Hash
ex) Monthly/Weekly count of unique users who triggered cli_template_included where label/property is… ex) Monthly/Weekly count of unique users who triggered cli_template_included (user unavailable)
202 203 204 205 206 207 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 202 def formatted name = [time_frame_phrase, operator_phrase, filter_phrase].compact.join(' ') name = format_help(name) if disabled { name: name, disabled: disabled, value: metric }.compact end |
#highlighted_phrase ⇒ Object
ex) “unique users”
229 230 231 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 229 def highlighted_phrase "#{metric.operator.qualifier} #{identifier.plural}" end |
#identifier ⇒ Object
209 210 211 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 209 def identifier metric.identifier end |
#operator_phrase ⇒ Object
ex) “count of unique users who triggered cli_template_included”
221 222 223 224 225 226 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 221 def operator_phrase phrase = "#{metric.operator.description} #{identifier.description % events_name}" phrase.gsub!(highlighted_phrase, format_info(highlighted_phrase)) unless disabled phrase end |
#time_frame_phrase ⇒ Object
ex) “Monthly/Weekly”
214 215 216 217 218 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 214 def time_frame_phrase phrase = metric.time_frame.description disabled ? phrase : format_info(phrase) end |