Module: RuboCop::Formatter::TextUtil

Included in:
CLI, HTMLFormatter::ERBContext, ProgressFormatter, SimpleTextFormatter
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
18
19
20
# File 'lib/rubocop/formatter/text_util.rb', line 9

def pluralize(number, thing, options = {})
  text = if number == 0 && options[:no_for_zero]
           'no'
         else
           number.to_s
         end

  text << " #{thing}"
  text << 's' unless number == 1

  text
end