aboutsummaryrefslogtreecommitdiff
path: root/pharo-mooc/contact-book/src/ContactBook/Contact.class.st
diff options
context:
space:
mode:
Diffstat (limited to 'pharo-mooc/contact-book/src/ContactBook/Contact.class.st')
-rw-r--r--pharo-mooc/contact-book/src/ContactBook/Contact.class.st62
1 files changed, 62 insertions, 0 deletions
diff --git a/pharo-mooc/contact-book/src/ContactBook/Contact.class.st b/pharo-mooc/contact-book/src/ContactBook/Contact.class.st
new file mode 100644
index 0000000..67ca674
--- /dev/null
+++ b/pharo-mooc/contact-book/src/ContactBook/Contact.class.st
@@ -0,0 +1,62 @@
+"
+I represent a person with a name and an email address. I'm usually
+part of a contact book.
+"
+Class {
+ #name : 'Contact',
+ #superclass : 'Object',
+ #instVars : [
+ 'fullname',
+ 'email'
+ ],
+ #category : 'ContactBook',
+ #package : 'ContactBook'
+}
+
+{ #category : 'instance creation' }
+Contact class >> newNamed: aNameString email: anEmailString [
+ ^ self new
+ fullname: aNameString;
+ email: anEmailString;
+ yourself
+]
+
+{ #category : 'accessing' }
+Contact >> email [
+
+ ^ email
+]
+
+{ #category : 'accessing' }
+Contact >> email: anObject [
+
+ email := anObject
+]
+
+{ #category : 'accessing' }
+Contact >> fullname [
+
+ ^ fullname
+]
+
+{ #category : 'accessing' }
+Contact >> fullname: aString [
+
+ fullname := aString
+]
+
+{ #category : 'as yet unclassified' }
+Contact >> gravatarUrl [
+ ^ 'http://www.gravatar.com/avatar/',
+ (MD5 hashMessage: email asString trimBoth asLowercase) hex,
+ '.jpg'
+]
+
+{ #category : 'accessing' }
+Contact >> printOn: aStream [
+ aStream
+ nextPutAll: self fullname;
+ nextPutAll: ' <';
+ nextPutAll: self email;
+ nextPutAll: '>'
+]