Module: Gamefic::Scriptable::Queries
- Includes:
- Proxies
- Included in:
- Narrative, Gamefic::Scriptable, Actions
- Defined in:
- lib/gamefic/scriptable/queries.rb
Overview
Scriptable methods related to creating action queries.
Instance Method Summary collapse
-
#abstract(*args, ambiguous: false) ⇒ Query::Abstract
Define a query that searches for abstract entities.
-
#anywhere(*args, ambiguous: false) ⇒ Query::General
Define a query that searches the entire plot’s entities.
-
#available(*args, ambiguous: false) ⇒ Query::Scoped
(also: #family)
Define a query that searches an actor’s family of entities.
-
#children(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that searches an actor’s children.
-
#descendants(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that searches an actor’s descendants.
-
#myself(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that returns the actor itself.
-
#parent(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that returns the actor’s parent.
-
#plaintext(arg = /.*/) ⇒ Query::Text
Define a query that performs a plaintext search.
-
#siblings(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that searches an actor’s siblings.
Methods included from Proxies
Instance Method Details
#abstract(*args, ambiguous: false) ⇒ Query::Abstract
Define a query that searches for abstract entities.
An abstract entity is a pseudo-entity that is describable but does not have a parent or children.
25 26 27 |
# File 'lib/gamefic/scriptable/queries.rb', line 25 def abstract *args, ambiguous: false Query::Abstract.new -> { entities }, *args, ambiguous: ambiguous end |
#anywhere(*args, ambiguous: false) ⇒ Query::General
Define a query that searches the entire plot’s entities.
14 15 16 |
# File 'lib/gamefic/scriptable/queries.rb', line 14 def anywhere *args, ambiguous: false Query::General.new -> { entities }, *args, ambiguous: ambiguous, name: 'anywhere' end |
#available(*args, ambiguous: false) ⇒ Query::Scoped Also known as: family
Define a query that searches an actor’s family of entities. The results include the parent, siblings, children, and accessible descendants of siblings and children.
35 36 37 |
# File 'lib/gamefic/scriptable/queries.rb', line 35 def available *args, ambiguous: false Query::Scoped.new Scope::Family, *args, ambiguous: ambiguous, name: 'available' end |
#children(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that searches an actor’s children.
52 53 54 |
# File 'lib/gamefic/scriptable/queries.rb', line 52 def children *args, ambiguous: false Query::Scoped.new Scope::Children, *args, ambiguous: ambiguous, name: 'children' end |
#descendants(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that searches an actor’s descendants.
60 61 62 |
# File 'lib/gamefic/scriptable/queries.rb', line 60 def descendants *args, ambiguous: false Query::Scoped.new Scope::Descendants, *args, ambiguous: ambiguous end |
#myself(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that returns the actor itself.
76 77 78 |
# File 'lib/gamefic/scriptable/queries.rb', line 76 def myself *args, ambiguous: false Query::Scoped.new Scope::Myself, *args, ambiguous: ambiguous, name: 'myself' end |
#parent(*args, ambiguous: false) ⇒ Query::Scoped
Define a query that returns the actor’s parent.
44 45 46 |
# File 'lib/gamefic/scriptable/queries.rb', line 44 def parent *args, ambiguous: false Query::Scoped.new Scope::Parent, *args, ambiguous: ambiguous, name: 'parent' end |
#plaintext(arg = /.*/) ⇒ Query::Text
Define a query that performs a plaintext search. It can take a String or a RegExp as an argument. If no argument is provided, it will match any text it finds in the command. A successful query returns the corresponding text instead of an entity.
87 88 89 |
# File 'lib/gamefic/scriptable/queries.rb', line 87 def plaintext arg = /.*/ Query::Text.new arg, name: 'plaintext' end |