No commit activity in last 3 years
No release in over 3 years
FullNameSplitter splits full name into first and last name considering name prefixes and initials
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

#FullNameSplitter

FullNameSplitter splits full name into first and last name considering name prefixes and initials

If you include the module it requires attribute accessors first_name and last_name and adds #full_name, #full_name= to the class

For example

require 'full_name_splitter'

class Incognito
  include FullNameSplitter
  attr_accessor :first_name, :last_name
end

incognito = Incognito.new :full_name => "George H. W. Bush"
incognito.first_name # => "George H. W."
incognito.last_name  # => "Bush"

incognito = Incognito.new :full_name => "Kevin J. O'Connor"
incognito.first_name # => "Kevin J."
incognito.last_name  # => "O'Connor"

incognito = Incognito.new :full_name => "Thomas G. Della Fave"
incognito.first_name # => "Thomas G."
incognito.last_name  # => "Della Fave"

incognito = Incognito.new :full_name => "Gabriel Van Helsing"
incognito.first_name # => "Gabriel"
incognito.last_name  # => "Van Helsing"

If full name isn't complete FullNameSplitter tries to split partially

incognito = Incognito.new :full_name => "George W."
incognito.first_name # => "George W."
incognito.last_name  # => nil

incognito = Incognito.new :full_name => "George"
incognito.first_name # => "George"
incognito.last_name  # => nil

incognito = Incognito.new :full_name => "Van Helsing"
incognito.first_name # => nil
incognito.last_name  # => "Van Helsing"

incognito = Incognito.new :full_name => "d'Artagnan"
incognito.first_name # => nil
incognito.last_name  # => "d'Artagnan"

For other examples see spec/lib/full_name_splitter_spec.rb

Also you can use splitter directly by calling module function FullNameSplitter::split

FullNameSplitter.split("Juan Martín de la Cruz Gómez")  # => ["Juan Martín", "de la Cruz Gómez"]
FullNameSplitter.split("Ludwig Mies van der Rohe")      # => ["Ludwig", "Mies van der Rohe"]

If the lib can't split a name correctly, it is possible to split by comma

FullNameSplitter.split("John Quincy Adams")   # => ["John Quincy", "Adams"]
FullNameSplitter.split("John, Quincy Adams")  # => ["John", "Quincy Adams"]

##Copyright

Created by Pavel Gorbokon. Contributed by Michael S. Klishin and Trevor Creech. Released under the MIT license.