Module: OptparseLite::Lingual

Included in:
AppSpec, Command, Help, Np, OptSpec, SubCommands
Defined in:
lib/optparse-lite.rb,
lib/optparse-lite.rb

Overview

forward declarations (everything is in alphabetical order):

Instance Method Summary collapse

Instance Method Details

#methodize(mixed) ⇒ Object



510
511
512
# File 'lib/optparse-lite.rb', line 510

def methodize mixed
  mixed.to_s.gsub(/[^a-z0-9_\?\!]/,'_')
end

#oxford_comma(items, sep = ' and ', comma = ', ') ⇒ Object



503
504
505
506
507
508
509
# File 'lib/optparse-lite.rb', line 503

def oxford_comma items, sep=' and ', comma=', '
  return '()' if items.size == 0
  return items[0] if items.size == 1
  seps = [sep, '']
  seps.insert(0,*Array.new(items.size - seps.size, comma))
  items.zip(seps).flatten.join('')
end