module Namae

Namae is a parser for human names. It recognizes personal names of various cultural backgrounds and tries to split them into their component parts (e.g., given and family names, honorifics etc.).

The main use case of Namae is to use the {Namae.parse .parse} or {Namae.parse! .parse!} method to parse a string of names and return a list of {Namae::Name Name} objects.

@example Name parsing

Namae.parse('Yukihiro "Matz" Matsumoto')
#=> [#<Name family="Matsumoto" given="Yukihiro" nick="Matz">]

Namae.parse('Torvalds, Linus and Cox, Alan')
#=> [#<Name family="Torvalds" given="Linus">, #<Name family="Cox" given="Alan">]

Public Instance Methods

configure() { |defaults| ... } click to toggle source

@yield [Hash] the parser's default configuration.

   # File lib/namae/utility.rb
48 def configure
49   yield Parser.defaults
50 end
options() click to toggle source

@return [Hash] the parser's current configuration.

   # File lib/namae/utility.rb
43 def options
44   Parser.instance.options
45 end
parse(names) click to toggle source

Parses the passed-in string and returns a list of names. Behaves like parse but returns an empty list for bad input without raising an error.

@see parse!

@param names [String] the name or names to be parsed @return [Array] the list of parsed names

   # File lib/namae/utility.rb
28 def parse(names)
29   Parser.instance.parse(names)
30 end
parse!(names) click to toggle source

Parses the passed-in string and returns a list of names.

@param names [String] the name or names to be parsed @return [Array] the list of parsed names

@raise [ArgumentError] if the string cannot be parsed.

   # File lib/namae/utility.rb
38 def parse!(names)
39   Parser.instance.parse!(names)
40 end