Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/turnsole/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ def eql? o; o.email == @email end
attr_reader :name, :email, :handle

def shortname
case @name
return @handle if !@name
# Remove (academic) titles for the short version of the name.
stripped_name = @name
['Dr', 'Prof', 'Mr', 'Mrs', 'Ms'].each do |title|
stripped_name = stripped_name.gsub(/#{title}.?\s/, '')
end
case stripped_name
when /\S+, (\S+)/; $1
when /(\S+) \S+/; $1
when nil; @handle
else @name
else stripped_name
end
end

Expand Down