Module: RuboCop::Formatter::TextUtil

Included in:
CLI, HTMLFormatter::ERBContext, PacmanFormatter, ProgressFormatter, SimpleTextFormatter::Report
Defined in:
lib/rubocop/formatter/text_util.rb

Overview

Common logic for UI texts.

Class Method Summary collapse

Class Method Details

.pluralize(number, thing, options = {}) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/rubocop/formatter/text_util.rb', line 9

def pluralize(number, thing, options = {})
  if number.zero? && options[:no_for_zero]
    "no #{thing}s"
  elsif number == 1
    "1 #{thing}"
  else
    "#{number} #{thing}s"
  end
end