Class: Gamefic::Query::General
- Defined in:
- lib/gamefic/query/general.rb
Overview
A General query accepts an array of entities to filter. Unlike Scoped queries, the resulting entities will not necessarily be in the actor’s immediate vicinity.
General queries can also be passed a Proc that returns an array of entities. If the Proc accepts an argument, it will be given the subject of the query.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(entities, *arguments, ambiguous: false) ⇒ General
constructor
A new instance of General.
- #query(subject, token) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(entities, *arguments, ambiguous: false) ⇒ General
Returns a new instance of General.
17 18 19 20 |
# File 'lib/gamefic/query/general.rb', line 17 def initialize entities, *arguments, ambiguous: false super(*arguments, ambiguous: ambiguous) @entities = entities end |
Instance Method Details
#query(subject, token) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/gamefic/query/general.rb', line 22 def query subject, token filtered = available_entities(subject).that_are(*@arguments) return Result.new(token, nil) if filtered.include?(token) scan = Scanner.scan(filtered, token) ambiguous? ? ambiguous_result(scan) : unambiguous_result(scan) end |