File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ from std/os import commandLineParams
77const BASE_URL = " https://api.github.com/users/"
88
99type
10- GthUserItem * = ref object
10+ GthUserItem * = object
1111 count* : int
1212 arr* : seq [string ]
1313
14- GthUser * = ref object
14+ GthUser * = object
1515 # Private
1616 obj: JsonNode
1717 url: string
2424 followers* : GthUserItem
2525 following* : GthUserItem
2626
27- proc newGthUser * (username: string ): GthUser =
28- var self = GthUser ()
27+ proc init * (self: var GthUser ; username: string ) =
2928 self.url = BASE_URL & username
30-
29+
3130 var res = newHttpClient ().getContent (self.url)
3231 self.obj = parseJson (res)
3332
@@ -40,9 +39,7 @@ proc newGthUser*(username: string): GthUser =
4039 self.followers = GthUserItem (count: self.obj[" followers" ].getInt ())
4140 self.following = GthUserItem (count: self.obj[" following" ].getInt ())
4241
43- return self
44-
45- method fetch * (self: GthUser , thing: string ): void {.base .} =
42+ proc fetch * (self: var GthUser ; thing: string ) =
4643 var
4744 url = self.url & '/' & thing
4845 res = newHttpClient ().getContent (url)
@@ -90,7 +87,8 @@ if args.len() == 0:
9087 echo " No arguments, nothing to do."
9188else :
9289 for username in args:
93- var user = newGthUser (username)
90+ var user = GthUser ()
91+ user.init (username)
9492
9593 echo " Name: " , user.name
9694 echo " Bio: " , user.bio
You can’t perform that action at this time.
0 commit comments