class References::Name
This class let work internal names of authors of a fancy way.
Attributes
names[R]
surnames[R]
Public Class Methods
new(surnames, names)
click to toggle source
Make a Name
object @param surnames [String] Take string with surnames of person of interest seperated with spaces. @param names [String] Take string with names of person of interest seperated with spaces.
# File lib/references/name.rb, line 10 def initialize(surnames, names) @surnames = surnames.split(" ") @names = names.split(" ") end
Public Instance Methods
<=>(other)
click to toggle source
Define the comparasion of names, in this case is with the first surname.
# File lib/references/name.rb, line 15 def <=>(other) other.surnames.first <=> @surnames.first end
to_s()
click to toggle source
Let convert a Name
object in a human readable String in fancy way too. @return [String]
# File lib/references/name.rb, line 21 def to_s @surnames.first + ", " + (@names.map { |x| x[0].upcase }).join(". ") + ". " end