Improving and cleaning: classes should take care of initializing simple objects collection of instances without creating new objects for that exclusive taks.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-11-10 15:45:32 -05:00
parent d004a7ec55
commit bd1257de86
10 changed files with 16 additions and 38 deletions

View File

@ -2,5 +2,9 @@ I model an asset of the Ironsworn Starforged Tabletop Roleplaying Game.
More information at:
[1] https://www.ironswornrpg.com/
[2] https://www.kickstarter.com/projects/shawntomkin/ironsworn-starforged
[1] <https://www.ironswornrpg.com/>
[2] <https://www.kickstarter.com/projects/shawntomkin/ironsworn-starforged>
I use as inspiration the data provided by @rsek at this repostory:
<https://github.com/rsek/datasworn>

View File

@ -0,0 +1,6 @@
accessing
collectionFromRepository: jsonFileUrl language: isoCode
| rawData |
rawData := STON fromString: jsonFileUrl asUrl retrieveContents.
^ (rawData at: 'Assets') collect: [:assetDict |
self new fromDictionary: assetDict; language: isoCode ]

View File

@ -0,0 +1,3 @@
accessing
collectionFromRepostory
^ self collectionFromRepository: 'https://raw.githubusercontent.com/rsek/dataforged/main/assets.json' language: 'en'

View File

@ -1,6 +1,6 @@
accessing
fromDictionary: aDictionary
name := aDictionary at: #Name.
category := aDictionary at: #Category.
category := aDictionary at: 'Asset Type'.
abilities := self populateAbilities: (aDictionary at: #Abilities)

View File

@ -1,4 +0,0 @@
I model a collection of Starforged assets.
I use as inspiration the data provided by @rsek at this repostory:
https://github.com/rsek/datasworn

View File

@ -1,4 +0,0 @@
instance creation
fromUrl: aString
"Convinience shortcut as most of resources are published originally in English."
^ self fromUrl: aString language: 'en'

View File

@ -1,8 +0,0 @@
accessing
fromUrl: aString language: isoCode
| rawData |
rawData := STON fromString: aString asUrl retrieveContents.
self items: ((rawData at: 'Assets') collect: [:assetDict |
SfAsset new fromDictionary: assetDict; language: isoCode ])

View File

@ -1,3 +0,0 @@
accessing
items: anObject
items := anObject

View File

@ -1,3 +0,0 @@
accessing
items
^ items ifNil: [ items := OrderedCollection ]

View File

@ -1,13 +0,0 @@
{
"commentStamp" : "GlamorousAuthor 5/17/2021 16:41",
"super" : "Object",
"category" : "RoloLudo",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"items"
],
"name" : "SfAssets",
"type" : "normal"
}