lib/nomen/formatters/full.rb in nomen-0.0.1 vs lib/nomen/formatters/full.rb in nomen-0.0.2
- old
+ new
@@ -1,20 +1,20 @@
-module Nomen
+class Nomen
module Formatters
class Full
def self.format(name)
String.new.tap do |str|
- if name.first
+ if name.first && !name.first.empty?
str << name.first
end
- if name.middle
+ if name.middle && !name.middle.empty?
str << (str.empty? ? name.middle : " #{name.middle}")
end
- if name.last
+ if name.last && !name.last.empty?
str << (str.empty? ? name.last : " #{name.last}")
end
- if name.suffix
+ if name.suffix && !name.suffix.empty?
str << (str.empty? ? name.suffix : " #{name.suffix}")
end
end
end