Skip to content

Commit

Permalink
Added support for GS query options
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabacman committed Jan 12, 2024
1 parent cb3f400 commit 4ed4a91
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
36 changes: 32 additions & 4 deletions source/Buoy-GS64-Compatibility/GsQuery.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,29 @@ Class {
#name : 'GsQuery',
#superclass : 'Object',
#instVars : [
'results'
'results',
'queryString'
],
#category : 'Buoy-GS64-Compatibility',
#package : 'Buoy-GS64-Compatibility'
}

{ #category : 'instance creation' }
GsQuery class >> fromString: aString [
GsQuery class >> fromString: aString options: anOption [

^ self new
^ self new initializeFromString: aString
]

{ #category : 'accessing' }
GsQuery >> asArray [

^ self queryResult asArray
]

{ #category : 'accessing' }
GsQuery >> asSet [

^ self queryResult asSet
]

{ #category : 'accessing' }
Expand All @@ -27,10 +40,25 @@ GsQuery >> do: aBlock [
^ self queryResult do: aBlock
]

{ #category : 'initialization' }
GsQuery >> initializeFromString: aString [

queryString := aString
]

{ #category : 'configuring' }
GsQuery >> on: anUnorderedCollection [

results := anUnorderedCollection select: [ :each | each firstName = 'Silvester' ]
( queryString includesSubstring: 'Silvester' ) ifTrue: [
^ results := anUnorderedCollection select: [ :each | each firstName = 'Silvester' ] ].

( queryString includesSubstring: 'SDF-1' ) ifTrue: [
^ results := anUnorderedCollection select: [ :each |
each name = 'SDF-1' and: ( each fleet anySatisfy: [ :ship | ship name = 'VF-1D' ] ) ]
].

( queryString includesSubstring: 'firepower' ) ifTrue: [
^ results := anUnorderedCollection select: [ :each | each firepower between: 2117 + 1 and: 8000 ] ]
]

{ #category : 'accessing' }
Expand Down
30 changes: 30 additions & 0 deletions source/Buoy-GS64-Compatibility/GsQueryOptions.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"
In GS64, GsQueryOptions is part of the Indexing and Querying subsystem. This class encapsulates the optional refinements that may be used when creating a particular query. Each GsQuery has an associated instance of GsQueryOptions, either the default one or an instance that is created and included in the GsQuery specification method.
This version is just a placeholder so we can easily create extensions methods to load in GS64 specific
packages.
"
Class {
#name : 'GsQueryOptions',
#superclass : 'Object',
#category : 'Buoy-GS64-Compatibility',
#package : 'Buoy-GS64-Compatibility'
}

{ #category : 'accessing' }
GsQueryOptions class >> cacheQueryResult [

^ self new
]

{ #category : 'accessing' }
GsQueryOptions class >> default [

^ self new
]

{ #category : 'combining' }
GsQueryOptions >> + anOption [

^ self
]

0 comments on commit 4ed4a91

Please sign in to comment.