Module: Suprdate::Utility

Defined in:
lib/suprdate.rb

Overview

Methods and classes used in the internals of Suprdate not expected to be of concern to the casual developer.

Defined Under Namespace

Modules: CleanConstantName

Class Method Summary collapse

Class Method Details

.disarray(array) ⇒ Object

:nodoc: all



10
11
12
# File 'lib/suprdate.rb', line 10

def self.disarray(array)
  if array.size == 1 then array[0] else array end
end

.english_list(items) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/suprdate.rb', line 14

def self.english_list(items)
  items = items.map { |x| x.to_s }
  case items.length
  when 1
    items[0]
  when 2
    items.join(' and ')
  else
    items[0..-2].join(', ') + ', and ' + items.last
  end
end