Module: RuboCop::Formatter::TextUtil

Included in:
CLI, HTMLFormatter::ERBContext, 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



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

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