Class: Gamefic::Query::Text
- Inherits:
-
Object
- Object
- Gamefic::Query::Text
- Defined in:
- lib/gamefic/query/text.rb
Overview
A special query that handles text instead of entities.
Instance Method Summary collapse
- #accept?(_subject, argument) ⇒ Boolean
- #ambiguous? ⇒ Boolean
-
#initialize(argument = /.*/) ⇒ Text
constructor
A new instance of Text.
- #precision ⇒ Object
- #query(_subject, token) ⇒ Object
- #select(_subject) ⇒ String, Regexp
Constructor Details
#initialize(argument = /.*/) ⇒ Text
Returns a new instance of Text.
9 10 11 12 |
# File 'lib/gamefic/query/text.rb', line 9 def initialize argument = /.*/ @argument = argument validate end |
Instance Method Details
#accept?(_subject, argument) ⇒ Boolean
31 32 33 |
# File 'lib/gamefic/query/text.rb', line 31 def accept? _subject, argument match? argument end |
#ambiguous? ⇒ Boolean
35 36 37 |
# File 'lib/gamefic/query/text.rb', line 35 def ambiguous? true end |
#precision ⇒ Object
27 28 29 |
# File 'lib/gamefic/query/text.rb', line 27 def precision 0 end |
#query(_subject, token) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/gamefic/query/text.rb', line 19 def query _subject, token if match? token Result.new(token, '') else Result.new(nil, token) end end |
#select(_subject) ⇒ String, Regexp
15 16 17 |
# File 'lib/gamefic/query/text.rb', line 15 def select(_subject) @argument end |