Editing initialize. Adding url and type lazy setters and collection of urtTypes.
This commit is contained in:
parent
4ede468c75
commit
33fa7599b9
@ -1,24 +1,25 @@
|
||||
Class {
|
||||
#name : #InstagramUrlTest,
|
||||
#superclass : #TestCase,
|
||||
#category : #'Instagram-Tests'
|
||||
#name : 'InstagramUrlTest',
|
||||
#superclass : 'TestCase',
|
||||
#category : 'Instagram-Tests',
|
||||
#package : 'Instagram-Tests'
|
||||
}
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
InstagramUrlTest >> testInstagramUrlInstanceCreation [
|
||||
| i |
|
||||
i := InstagramUrl newURL: 'instagram.com'.
|
||||
self assert: i url asStringOrText equals: 'https://instagram.com/'
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
InstagramUrlTest >> testNotInstagramUrl1 [
|
||||
| i |
|
||||
i := InstagramUrl newURL: 'nstgrm.com'.
|
||||
self assert: i url asStringOrText equals: 'https://www.instagram.com/'
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
{ #category : 'tests' }
|
||||
InstagramUrlTest >> testNotInstagramUrl2 [
|
||||
| i |
|
||||
i := InstagramUrl newURL: 'nstgrm.com'.
|
||||
|
@ -1 +1 @@
|
||||
Package { #name : #'Instagram-Tests' }
|
||||
Package { #name : 'Instagram-Tests' }
|
||||
|
@ -7,7 +7,8 @@ Class {
|
||||
#name : 'InstagramUrl',
|
||||
#superclass : 'Object',
|
||||
#instVars : [
|
||||
'url'
|
||||
'url',
|
||||
'type'
|
||||
],
|
||||
#category : 'Instagram',
|
||||
#package : 'Instagram'
|
||||
@ -23,10 +24,10 @@ InstagramUrl class >> newURL: url [
|
||||
|
||||
{ #category : 'initialization' }
|
||||
InstagramUrl >> initialize [
|
||||
| initial |
|
||||
initial := 'https://www.instagram.com' asUrl.
|
||||
|
||||
super initialize.
|
||||
self url: initial.
|
||||
self url.
|
||||
self type.
|
||||
|
||||
|
||||
]
|
||||
@ -36,10 +37,16 @@ InstagramUrl >> openWithoutTracking [
|
||||
WebBrowser openOn: self urlWithoutTracking
|
||||
]
|
||||
|
||||
{ #category : 'accessing' }
|
||||
InstagramUrl >> type [
|
||||
|
||||
^ type
|
||||
]
|
||||
|
||||
{ #category : 'accessing' }
|
||||
InstagramUrl >> url [
|
||||
|
||||
^ url
|
||||
^ url ifNil: [ url := 'https://instagram.com/' asUrl ]
|
||||
]
|
||||
|
||||
{ #category : 'accessing' }
|
||||
@ -48,17 +55,11 @@ InstagramUrl >> url: aURL [
|
||||
url := aURL
|
||||
]
|
||||
|
||||
{ #category : 'testing' }
|
||||
InstagramUrl >> urlCheck: aURLString [
|
||||
| urlCheck |
|
||||
(aURLString includesSubstring: 'instagram.com')
|
||||
ifFalse: [ UIManager default inform: '" ', aURLString, ' " it''s not an instagram URL.'.
|
||||
^ self url].
|
||||
urlCheck := aURLString asUrl.
|
||||
urlCheck hasHost ifFalse: [ urlCheck host: urlCheck segments first.
|
||||
urlCheck removeFirstPathSegment. ].
|
||||
urlCheck hasScheme ifFalse: [ urlCheck scheme: 'https' ].
|
||||
^ urlCheck
|
||||
{ #category : 'accessing - data' }
|
||||
InstagramUrl >> urlTypes [
|
||||
"I have the collection of correct types."
|
||||
|
||||
^ { 'root' . 'user' }
|
||||
]
|
||||
|
||||
{ #category : 'accessing' }
|
||||
|
Loading…
Reference in New Issue
Block a user