class Gamefic::Query::General
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.
Public Class Methods
new(entities, *arguments, ambiguous: false, name: nil)
click to toggle source
@param entities [Array, Proc] @param arguments [Array<Object>] @param ambiguous [Boolean]
Calls superclass method
Gamefic::Query::Base::new
# File lib/gamefic/query/general.rb, line 17 def initialize entities, *arguments, ambiguous: false, name: nil super(*arguments, ambiguous: ambiguous, name: name) @entities = entities end
Public Instance Methods
span(subject)
click to toggle source
# File lib/gamefic/query/general.rb, line 22 def span subject available_entities(subject) end
Private Instance Methods
available_entities(subject)
click to toggle source
# File lib/gamefic/query/general.rb, line 28 def available_entities(subject) if @entities.is_a?(Proc) if @entities.arity.zero? Stage.run narrative, &@entities else Stage.run narrative, subject, &@entities end else @entities end end