Class: Gamefic::Query::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/query/text.rb

Overview

A special query that handles text instead of entities.

Instance Method Summary collapse

Constructor Details

#initialize(argument = /.*/) ⇒ Text

Returns a new instance of Text.

Parameters:

  • argument (String, Regexp) (defaults to: /.*/)


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

Returns:

  • (Boolean)


31
32
33
# File 'lib/gamefic/query/text.rb', line 31

def accept? _subject, argument
  match? argument
end

#ambiguous?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/gamefic/query/text.rb', line 35

def ambiguous?
  true
end

#precisionObject



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

Returns:



15
16
17
# File 'lib/gamefic/query/text.rb', line 15

def select(_subject)
  @argument
end