Class: Gamefic::Query::Scoped
Overview
A Scoped query uses a Scope to select entities to filter based on their relationship to the entity performing the query. For example, Scope::Children would filter from an array of the entity’s descendants.
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Attributes inherited from Base
#ambiguous, #arguments, #narrative
Instance Method Summary collapse
-
#initialize(scope, *arguments, ambiguous: false, name: nil) ⇒ Scoped
constructor
A new instance of Scoped.
- #precision ⇒ Object
- #span(subject) ⇒ Object
Methods inherited from Base
#accept?, #ambiguous?, #inspect, #name, #query, #select
Constructor Details
#initialize(scope, *arguments, ambiguous: false, name: nil) ⇒ Scoped
Returns a new instance of Scoped.
13 14 15 16 |
# File 'lib/gamefic/query/scoped.rb', line 13 def initialize scope, *arguments, ambiguous: false, name: nil super(*arguments, ambiguous: ambiguous, name: name) @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
10 11 12 |
# File 'lib/gamefic/query/scoped.rb', line 10 def scope @scope end |
Instance Method Details
#precision ⇒ Object
22 23 24 |
# File 'lib/gamefic/query/scoped.rb', line 22 def precision @precision ||= @scope.precision + calculate_precision end |
#span(subject) ⇒ Object
18 19 20 |
# File 'lib/gamefic/query/scoped.rb', line 18 def span(subject) @scope.matches(subject) end |