class Namie::Formatter

Format name

Constants

ABBR
FORMATS

Attributes

format[RW]
name[RW]
out[RW]

Public Class Methods

new(name, format) click to toggle source
# File lib/namie/formatter.rb, line 19
def initialize(name, format)
  @name = name
  format ||= :default
  @format = format.is_a?(Symbol) ? FORMATS[format] : format
  @out = @format.dup
end

Public Instance Methods

to_s() click to toggle source

%t Title %f First Name %m Middle Name(s) %l Last Name %s suffix

# File lib/namie/formatter.rb, line 33
def to_s
  ABBR.each do |k, v|
    val = name.send(v)
    out.gsub!("%#{k}", val || '')
  end
  out.gsub(/\s{2,}/, ' ').strip.chomp
end