From c03c9f8b886c0e8eca5a701c0ca941e05e0b6285 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 21 Nov 2025 22:20:10 +0100 Subject: Add pharo tiny blog --- pharo-mooc/tiny-blog/src/TinyBlog/TBPost.class.st | 121 ++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 pharo-mooc/tiny-blog/src/TinyBlog/TBPost.class.st (limited to 'pharo-mooc/tiny-blog/src/TinyBlog/TBPost.class.st') diff --git a/pharo-mooc/tiny-blog/src/TinyBlog/TBPost.class.st b/pharo-mooc/tiny-blog/src/TinyBlog/TBPost.class.st new file mode 100644 index 0000000..08e8247 --- /dev/null +++ b/pharo-mooc/tiny-blog/src/TinyBlog/TBPost.class.st @@ -0,0 +1,121 @@ +Class { + #name : 'TBPost', + #superclass : 'Object', + #instVars : [ + 'title', + 'text', + 'date', + 'category', + 'visible' + ], + #category : 'TinyBlog', + #package : 'TinyBlog' +} + +{ #category : 'instance creation' } +TBPost class >> title: aTitle text: aText [ + ^ self new + title: aTitle; + text: aText; + yourself +] + +{ #category : 'instance creation' } +TBPost class >> title: aTitle text: aText category: aCategory [ + ^ (self title: aTitle text: aText) + category: aCategory; + yourself +] + +{ #category : 'as yet unclassified' } +TBPost class >> unclassifiedTag [ + ^ 'Unclassified' +] + +{ #category : 'action' } +TBPost >> beVisible [ + self visible: true +] + +{ #category : 'accessing' } +TBPost >> category [ + + ^ category +] + +{ #category : 'accessing' } +TBPost >> category: anObject [ + + category := anObject +] + +{ #category : 'accessing' } +TBPost >> date [ + + ^ date +] + +{ #category : 'accessing' } +TBPost >> date: anObject [ + + date := anObject +] + +{ #category : 'initialization' } +TBPost >> initialize [ + super initialize. + self category: self class unclassifiedTag. + self date: Date today. + self notVisible. +] + +{ #category : 'testing' } +TBPost >> isUnclassified [ + ^ self category = self class unclassifiedTag +] + +{ #category : 'testing' } +TBPost >> isVisible [ + ^ self visible +] + +{ #category : 'action' } +TBPost >> notVisible [ + self visible: false +] + +{ #category : 'accessing' } +TBPost >> text [ + + ^ text +] + +{ #category : 'accessing' } +TBPost >> text: anObject [ + + text := anObject +] + +{ #category : 'accessing' } +TBPost >> title [ + + ^ title +] + +{ #category : 'accessing' } +TBPost >> title: anObject [ + + title := anObject +] + +{ #category : 'accessing' } +TBPost >> visible [ + + ^ visible +] + +{ #category : 'accessing' } +TBPost >> visible: anObject [ + + visible := anObject +] -- cgit v1.2.3