Class: Gamefic::Query::General

Inherits:
Base
  • Object
show all
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.

Direct Known Subclasses

Abstract

Instance Attribute Summary

Attributes inherited from Base

#ambiguous, #arguments, #narrative

Instance Method Summary collapse

Methods inherited from Base

#accept?, #ambiguous?, #inspect, #name, #precision, #query, #select

Constructor Details

#initialize(entities, *arguments, ambiguous: false, name: nil) ⇒ General

Returns a new instance of General.

Parameters:

  • entities (Array, Proc)
  • arguments (Array<Object>)
  • ambiguous (Boolean) (defaults to: false)


17
18
19
20
# 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

Instance Method Details

#span(subject) ⇒ Object



22
23
24
# File 'lib/gamefic/query/general.rb', line 22

def span subject
  available_entities(subject)
end