commit 7eb4665b0973f3bada55029a5d74a052014e7993
parent 06cae7934249af941b7c0825b2f4773cbea3cd26
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Sat, 26 Sep 2009 06:36:54 -0700
minor bugfix: set Person @name to nil
Idea thanks to Carl Worth
Diffstat:
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/lib/sup/person.rb b/lib/sup/person.rb
@@ -1,19 +1,17 @@
module Redwood
-class Person
+class Person
attr_accessor :name, :email
def initialize name, email
raise ArgumentError, "email can't be nil" unless email
-
- if name
- @name = name.gsub(/^\s+|\s+$/, "").gsub(/\s+/, " ")
- if @name =~ /^(['"]\s*)(.*?)(\s*["'])$/
- @name = $2
- end
+
+ @name = if name
+ name = name.strip.gsub(/\s+/, " ")
+ name =~ /^(['"]\s*)(.*?)(\s*["'])$/ ? $2 : name
end
- @email = email.gsub(/^\s+|\s+$/, "").gsub(/\s+/, " ").downcase
+ @email = email.strip.gsub(/\s+/, " ").downcase
end
def to_s; "#@name <#@email>" end