Class: Gamefic::Query::Base
- Inherits:
-
Object
- Object
- Gamefic::Query::Base
- Defined in:
- lib/gamefic/query/base.rb
Overview
A base class for entity-based queries that can be applied to responses. Each query represents an attempt to match an argument in a command to a game entity.
Instance Attribute Summary collapse
- #ambiguous ⇒ Boolean readonly
- #arguments ⇒ Array<Object> readonly
Instance Method Summary collapse
- #ambiguous? ⇒ Boolean
-
#initialize(*arguments, ambiguous: false) ⇒ Base
constructor
A new instance of Base.
- #precision ⇒ Integer
- #query(subject, token) ⇒ Result
Constructor Details
#initialize(*arguments, ambiguous: false) ⇒ Base
Returns a new instance of Base.
20 21 22 23 24 25 |
# File 'lib/gamefic/query/base.rb', line 20 def initialize *arguments, ambiguous: false raise ArgumentError, "nil argument in query" if arguments.any?(&:nil?) @arguments = arguments @ambiguous = ambiguous end |
Instance Attribute Details
#ambiguous ⇒ Boolean (readonly)
14 15 16 |
# File 'lib/gamefic/query/base.rb', line 14 def ambiguous @ambiguous end |
#arguments ⇒ Array<Object> (readonly)
11 12 13 |
# File 'lib/gamefic/query/base.rb', line 11 def arguments @arguments end |
Instance Method Details
#ambiguous? ⇒ Boolean
39 40 41 |
# File 'lib/gamefic/query/base.rb', line 39 def ambiguous? @ambiguous end |
#precision ⇒ Integer
35 36 37 |
# File 'lib/gamefic/query/base.rb', line 35 def precision @precision ||= calculate_precision end |
#query(subject, token) ⇒ Result
30 31 32 |
# File 'lib/gamefic/query/base.rb', line 30 def query(subject, token) raise "#query not implemented for #{self.class}" end |