class Gamefic::Query::Integer
A special query that handles integers instead of entities.
Public Class Methods
Source
# File lib/gamefic/query/integer.rb, line 9 def initialize(name: self.class.name) super(name: name) end
@param name [String, nil]
Calls superclass method
Gamefic::Query::Base::new
Public Instance Methods
Source
# File lib/gamefic/query/integer.rb, line 27 def accept?(_subject, token) token.is_a?(::Integer) end
Source
# File lib/gamefic/query/integer.rb, line 13 def filter(_subject, token) return Result.new(token, '') if token.is_a?(::Integer) words = token.keywords number = words.shift return Result.new(nil, token) unless number =~ /\d+/ Result.new(number.to_i, words.join(' ')) end